annotate third_party/raylib/include/rlgl.h @ 276:b55c22cff335

Add interactive infinite canvas prototype
author MrJuneJune <me@mrjunejune.com>
date Mon, 17 Aug 2026 16:57:56 -0700
parents f33d9ff8b6e8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1 /**********************************************************************************************
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2 *
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3 * rlgl v6.0 - A multi-OpenGL abstraction layer with an immediate-mode style API
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5 * DESCRIPTION:
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
6 * An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0, ES 3.0)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
7 * that provides a pseudo-OpenGL 1.1 immediate-mode style API (rlVertex, rlTranslate, rlRotate...)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
8 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
9 * ADDITIONAL NOTES:
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
10 * When choosing an OpenGL backend different than OpenGL 1.1, some internal buffers are
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
11 * initialized on rlglInit() to accumulate vertex data
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
12 *
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
13 * When an internal state change is required all the stored vertex data is rendered in a batch,
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
14 * additionally, rlDrawRenderBatchActive() could be called to force flushing of the batch
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
15 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
16 * Some resources are also loaded for convenience, here the complete list:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
17 * - Default batch (RLGL.defaultBatch): RenderBatch system to accumulate vertex data
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
18 * - Default texture (RLGL.defaultTextureId): 1x1 white pixel R8G8B8A8
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
19 * - Default shader (RLGL.State.defaultShaderId, RLGL.State.defaultShaderLocs)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
20 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
21 * Internal buffer (and resources) must be manually unloaded calling rlglClose()
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
22 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
23 * CONFIGURATION:
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
24 * #define GRAPHICS_API_OPENGL_SOFTWARE
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
25 * #define GRAPHICS_API_OPENGL_11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
26 * #define GRAPHICS_API_OPENGL_21
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
27 * #define GRAPHICS_API_OPENGL_33
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
28 * #define GRAPHICS_API_OPENGL_43
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
29 * #define GRAPHICS_API_OPENGL_ES2
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
30 * #define GRAPHICS_API_OPENGL_ES3
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
31 * Use selected OpenGL graphics backend, should be supported by platform
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
32 * Those preprocessor defines are only used on the rlgl module, if OpenGL version is
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
33 * required by any other module, use rlGetVersion() to check it
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
34 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
35 * #define RLGL_IMPLEMENTATION
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
36 * Generates the implementation of the library into the included file
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
37 * If not defined, the library is in header only mode and can be included in other headers
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
38 * or source files without problems. But only ONE file should hold the implementation
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
39 *
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
40 * #if RLGL_SHOW_GL_DETAILS_INFO
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
41 * Show OpenGL extensions and capabilities detailed logs on init
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
42 *
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
43 * #if RLGL_ENABLE_OPENGL_DEBUG_CONTEXT
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
44 * Enable debug context (only available on OpenGL 4.3)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
45 *
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
46 * rlgl capabilities could be customized defining some internal
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
47 * values before library inclusion (default values listed):
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
48 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
49 * #define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 8192 // Default internal render batch elements limits
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
50 * #define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
51 * #define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
52 * #define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of texture units that can be activated on batch drawing (SetShaderValueTexture())
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
53 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
54 * #define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
55 * #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
56 * #define RL_CULL_DISTANCE_NEAR 0.05 // Default projection matrix near cull distance
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
57 * #define RL_CULL_DISTANCE_FAR 4000.0 // Default projection matrix far cull distance
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
58 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
59 * When loading a shader, the following vertex attributes and uniform
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
60 * location names are tried to be set automatically:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
61 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
62 * #define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
63 * #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
64 * #define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
65 * #define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
66 * #define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
67 * #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
68 * #define RL_DEFAULT_SHADER_ATTRIB_NAME_BONEINDICES "vertexBoneIndices" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
69 * #define RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS "vertexBoneWeights" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
70 * #define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
71 * #define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
72 * #define RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
73 * #define RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
74 * #define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView)))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
75 * #define RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (base tint color, multiplied by texture color)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
76 * #define RL_DEFAULT_SHADER_UNIFORM_NAME_BONEMATRICES "boneMatrices" // bone matrices
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
77 * #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
78 * #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
79 * #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
80 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
81 * DEPENDENCIES:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
82 * - OpenGL libraries (depending on platform and OpenGL version selected)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
83 * - GLAD OpenGL extensions loading library (only for OpenGL 3.3 Core, 4.3 Core)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
84 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
85 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
86 * LICENSE: zlib/libpng
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
87 *
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
88 * Copyright (c) 2014-2026 Ramon Santamaria (@raysan5)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
89 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
90 * This software is provided "as-is", without any express or implied warranty. In no event
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
91 * will the authors be held liable for any damages arising from the use of this software.
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
92 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
93 * Permission is granted to anyone to use this software for any purpose, including commercial
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
94 * applications, and to alter it and redistribute it freely, subject to the following restrictions:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
95 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
96 * 1. The origin of this software must not be misrepresented; you must not claim that you
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
97 * wrote the original software. If you use this software in a product, an acknowledgment
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
98 * in the product documentation would be appreciated but is not required.
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
99 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
100 * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
101 * as being the original software.
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
102 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
103 * 3. This notice may not be removed or altered from any source distribution.
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
104 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
105 **********************************************************************************************/
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
106
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
107 #ifndef RLGL_H
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
108 #define RLGL_H
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
109
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
110 #define RLGL_VERSION "6.0"
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
111
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
112 // Function specifiers in case library is build/used as a shared library
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
113 // NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
114 // NOTE: visibility(default) attribute makes symbols "visible" when compiled with -fvisibility=hidden
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
115 #if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
116 #define RLAPI __declspec(dllexport) // Building the library as a Win32 shared library (.dll)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
117 #elif defined(BUILD_LIBTYPE_SHARED)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
118 #define RLAPI __attribute__((visibility("default"))) // Building the library as a Unix shared library (.so/.dylib)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
119 #elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
120 #define RLAPI __declspec(dllimport) // Using the library as a Win32 shared library (.dll)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
121 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
122
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
123 // Function specifiers definition
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
124 #ifndef RLAPI
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
125 #define RLAPI // Functions defined as 'extern' by default (implicit specifiers)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
126 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
127
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
128 // Support TRACELOG macros
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
129 #ifndef TRACELOG
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
130 #define TRACELOG(level, ...) (void)0
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
131 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
132
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
133 // Allow custom memory allocators
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
134 #ifndef RL_MALLOC
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
135 #define RL_MALLOC(sz) malloc(sz)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
136 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
137 #ifndef RL_CALLOC
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
138 #define RL_CALLOC(n,sz) calloc(n,sz)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
139 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
140 #ifndef RL_REALLOC
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
141 #define RL_REALLOC(n,sz) realloc(n,sz)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
142 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
143 #ifndef RL_FREE
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
144 #define RL_FREE(p) free(p)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
145 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
146
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
147 // Security check in case no GRAPHICS_API_OPENGL_* defined
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
148 #if !defined(GRAPHICS_API_OPENGL_SOFTWARE) && \
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
149 !defined(GRAPHICS_API_OPENGL_11) && \
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
150 !defined(GRAPHICS_API_OPENGL_21) && \
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
151 !defined(GRAPHICS_API_OPENGL_33) && \
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
152 !defined(GRAPHICS_API_OPENGL_43) && \
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
153 !defined(GRAPHICS_API_OPENGL_ES2) && \
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
154 !defined(GRAPHICS_API_OPENGL_ES3)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
155 #define GRAPHICS_API_OPENGL_33
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
156 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
157
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
158 // Security check in case multiple GRAPHICS_API_OPENGL_* defined
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
159 #if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_SOFTWARE)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
160 #if defined(GRAPHICS_API_OPENGL_21)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
161 #undef GRAPHICS_API_OPENGL_21
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
162 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
163 #if defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
164 #undef GRAPHICS_API_OPENGL_33
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
165 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
166 #if defined(GRAPHICS_API_OPENGL_43)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
167 #undef GRAPHICS_API_OPENGL_43
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
168 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
169 #if defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
170 #undef GRAPHICS_API_OPENGL_ES2
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
171 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
172 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
173
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
174 // Software implementation uses OpenGL 1.1 functionality
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
175 #if defined(GRAPHICS_API_OPENGL_SOFTWARE)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
176 #define GRAPHICS_API_OPENGL_11
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
177 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
178
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
179 // OpenGL 2.1 uses most of OpenGL 3.3 Core functionality
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
180 // WARNING: Specific parts are checked with #if defines
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
181 #if defined(GRAPHICS_API_OPENGL_21)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
182 #define GRAPHICS_API_OPENGL_33
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
183 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
184
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
185 // OpenGL 4.3 uses OpenGL 3.3 Core functionality
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
186 #if defined(GRAPHICS_API_OPENGL_43)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
187 #define GRAPHICS_API_OPENGL_33
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
188 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
189
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
190 // OpenGL ES 3.0 uses OpenGL ES 2.0 functionality (and more)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
191 #if defined(GRAPHICS_API_OPENGL_ES3)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
192 #define GRAPHICS_API_OPENGL_ES2
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
193 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
194
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
195 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
196 // Defines and Macros
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
197 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
198
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
199 // Default internal render batch elements limits
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
200 #ifndef RL_DEFAULT_BATCH_BUFFER_ELEMENTS
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
201 #if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
202 // This is the maximum amount of elements (quads) per batch
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
203 // NOTE: Be careful with text, every letter maps to a quad
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
204 #define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 8192
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
205 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
206 #if defined(GRAPHICS_API_OPENGL_ES2)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
207 // Reducing memory sizes for embedded systems (RPI and HTML5)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
208 // NOTE: On HTML5 (emscripten) this is allocated on heap,
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
209 // by default heap is only 16MB!...just take care...
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
210 #define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 2048
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
211 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
212 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
213 #ifndef RL_DEFAULT_BATCH_BUFFERS
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
214 #define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
215 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
216 #ifndef RL_DEFAULT_BATCH_DRAWCALLS
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
217 #define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
218 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
219 #ifndef RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
220 #define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture())
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
221 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
222
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
223 // Internal Matrix stack
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
224 #ifndef RL_MAX_MATRIX_STACK_SIZE
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
225 #define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of Matrix stack
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
226 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
227
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
228 // Shader limits
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
229 #ifndef RL_MAX_SHADER_LOCATIONS
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
230 #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
231 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
232
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
233 // Projection matrix culling
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
234 #ifndef RL_CULL_DISTANCE_NEAR
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
235 #define RL_CULL_DISTANCE_NEAR 0.05 // Default near cull distance
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
236 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
237 #ifndef RL_CULL_DISTANCE_FAR
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
238 #define RL_CULL_DISTANCE_FAR 4000.0 // Default far cull distance
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
239 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
240
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
241 // Texture parameters (equivalent to OpenGL defines)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
242 #define RL_TEXTURE_WRAP_S 0x2802 // GL_TEXTURE_WRAP_S
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
243 #define RL_TEXTURE_WRAP_T 0x2803 // GL_TEXTURE_WRAP_T
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
244 #define RL_TEXTURE_MAG_FILTER 0x2800 // GL_TEXTURE_MAG_FILTER
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
245 #define RL_TEXTURE_MIN_FILTER 0x2801 // GL_TEXTURE_MIN_FILTER
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
246
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
247 #define RL_TEXTURE_FILTER_NEAREST 0x2600 // GL_NEAREST
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
248 #define RL_TEXTURE_FILTER_LINEAR 0x2601 // GL_LINEAR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
249 #define RL_TEXTURE_FILTER_MIP_NEAREST 0x2700 // GL_NEAREST_MIPMAP_NEAREST
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
250 #define RL_TEXTURE_FILTER_NEAREST_MIP_LINEAR 0x2702 // GL_NEAREST_MIPMAP_LINEAR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
251 #define RL_TEXTURE_FILTER_LINEAR_MIP_NEAREST 0x2701 // GL_LINEAR_MIPMAP_NEAREST
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
252 #define RL_TEXTURE_FILTER_MIP_LINEAR 0x2703 // GL_LINEAR_MIPMAP_LINEAR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
253 #define RL_TEXTURE_FILTER_ANISOTROPIC 0x3000 // Anisotropic filter (custom identifier)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
254 #define RL_TEXTURE_MIPMAP_BIAS_RATIO 0x4000 // Texture mipmap bias, percentage ratio (custom identifier)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
255
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
256 #define RL_TEXTURE_WRAP_REPEAT 0x2901 // GL_REPEAT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
257 #define RL_TEXTURE_WRAP_CLAMP 0x812F // GL_CLAMP_TO_EDGE
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
258 #define RL_TEXTURE_WRAP_MIRROR_REPEAT 0x8370 // GL_MIRRORED_REPEAT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
259 #define RL_TEXTURE_WRAP_MIRROR_CLAMP 0x8742 // GL_MIRROR_CLAMP_EXT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
260
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
261 // Matrix modes (equivalent to OpenGL)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
262 #define RL_MODELVIEW 0x1700 // GL_MODELVIEW
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
263 #define RL_PROJECTION 0x1701 // GL_PROJECTION
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
264 #define RL_TEXTURE 0x1702 // GL_TEXTURE
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
265
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
266 // Primitive assembly draw modes
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
267 #define RL_LINES 0x0001 // GL_LINES
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
268 #define RL_TRIANGLES 0x0004 // GL_TRIANGLES
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
269 #define RL_QUADS 0x0007 // GL_QUADS
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
270
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
271 // GL equivalent data types
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
272 #define RL_UNSIGNED_BYTE 0x1401 // GL_UNSIGNED_BYTE
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
273 #define RL_FLOAT 0x1406 // GL_FLOAT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
274
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
275 // GL buffer usage hint
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
276 #define RL_STREAM_DRAW 0x88E0 // GL_STREAM_DRAW
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
277 #define RL_STREAM_READ 0x88E1 // GL_STREAM_READ
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
278 #define RL_STREAM_COPY 0x88E2 // GL_STREAM_COPY
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
279 #define RL_STATIC_DRAW 0x88E4 // GL_STATIC_DRAW
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
280 #define RL_STATIC_READ 0x88E5 // GL_STATIC_READ
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
281 #define RL_STATIC_COPY 0x88E6 // GL_STATIC_COPY
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
282 #define RL_DYNAMIC_DRAW 0x88E8 // GL_DYNAMIC_DRAW
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
283 #define RL_DYNAMIC_READ 0x88E9 // GL_DYNAMIC_READ
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
284 #define RL_DYNAMIC_COPY 0x88EA // GL_DYNAMIC_COPY
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
285
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
286 // GL Shader type
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
287 #define RL_FRAGMENT_SHADER 0x8B30 // GL_FRAGMENT_SHADER
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
288 #define RL_VERTEX_SHADER 0x8B31 // GL_VERTEX_SHADER
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
289 #define RL_COMPUTE_SHADER 0x91B9 // GL_COMPUTE_SHADER
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
290
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
291 // GL blending factors
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
292 #define RL_ZERO 0 // GL_ZERO
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
293 #define RL_ONE 1 // GL_ONE
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
294 #define RL_SRC_COLOR 0x0300 // GL_SRC_COLOR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
295 #define RL_ONE_MINUS_SRC_COLOR 0x0301 // GL_ONE_MINUS_SRC_COLOR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
296 #define RL_SRC_ALPHA 0x0302 // GL_SRC_ALPHA
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
297 #define RL_ONE_MINUS_SRC_ALPHA 0x0303 // GL_ONE_MINUS_SRC_ALPHA
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
298 #define RL_DST_ALPHA 0x0304 // GL_DST_ALPHA
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
299 #define RL_ONE_MINUS_DST_ALPHA 0x0305 // GL_ONE_MINUS_DST_ALPHA
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
300 #define RL_DST_COLOR 0x0306 // GL_DST_COLOR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
301 #define RL_ONE_MINUS_DST_COLOR 0x0307 // GL_ONE_MINUS_DST_COLOR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
302 #define RL_SRC_ALPHA_SATURATE 0x0308 // GL_SRC_ALPHA_SATURATE
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
303 #define RL_CONSTANT_COLOR 0x8001 // GL_CONSTANT_COLOR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
304 #define RL_ONE_MINUS_CONSTANT_COLOR 0x8002 // GL_ONE_MINUS_CONSTANT_COLOR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
305 #define RL_CONSTANT_ALPHA 0x8003 // GL_CONSTANT_ALPHA
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
306 #define RL_ONE_MINUS_CONSTANT_ALPHA 0x8004 // GL_ONE_MINUS_CONSTANT_ALPHA
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
307
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
308 // GL blending functions/equations
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
309 #define RL_FUNC_ADD 0x8006 // GL_FUNC_ADD
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
310 #define RL_MIN 0x8007 // GL_MIN
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
311 #define RL_MAX 0x8008 // GL_MAX
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
312 #define RL_FUNC_SUBTRACT 0x800A // GL_FUNC_SUBTRACT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
313 #define RL_FUNC_REVERSE_SUBTRACT 0x800B // GL_FUNC_REVERSE_SUBTRACT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
314 #define RL_BLEND_EQUATION 0x8009 // GL_BLEND_EQUATION
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
315 #define RL_BLEND_EQUATION_RGB 0x8009 // GL_BLEND_EQUATION_RGB // (Same as BLEND_EQUATION)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
316 #define RL_BLEND_EQUATION_ALPHA 0x883D // GL_BLEND_EQUATION_ALPHA
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
317 #define RL_BLEND_DST_RGB 0x80C8 // GL_BLEND_DST_RGB
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
318 #define RL_BLEND_SRC_RGB 0x80C9 // GL_BLEND_SRC_RGB
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
319 #define RL_BLEND_DST_ALPHA 0x80CA // GL_BLEND_DST_ALPHA
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
320 #define RL_BLEND_SRC_ALPHA 0x80CB // GL_BLEND_SRC_ALPHA
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
321 #define RL_BLEND_COLOR 0x8005 // GL_BLEND_COLOR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
322
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
323 #define RL_READ_FRAMEBUFFER 0x8CA8 // GL_READ_FRAMEBUFFER
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
324 #define RL_DRAW_FRAMEBUFFER 0x8CA9 // GL_DRAW_FRAMEBUFFER
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
325
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
326 // Default shader vertex attribute locations
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
327 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
328 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION 0
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
329 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
330 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
331 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD 1
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
332 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
333 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
334 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL 2
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
335 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
336 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
337 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR 3
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
338 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
339 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
340 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT 4
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
341 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
342 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
343 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 5
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
344 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
345 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
346 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES 6
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
347 #endif
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
348 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
349 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES 7
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
350 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
351 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
352 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS 8
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
353 #endif
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
354 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCETRANSFORM
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
355 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCETRANSFORM 9
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
356 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
357
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
358 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
359 // Types and Structures Definition
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
360 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
361 #if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
362 #include <stdbool.h>
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
363 #elif !defined(__cplusplus) && !defined(bool) && !defined(RL_BOOL_TYPE)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
364 // Boolean type
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
365 typedef enum bool { false = 0, true = !false } bool;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
366 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
367
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
368 #if !defined(RL_MATRIX_TYPE)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
369 // Matrix, 4x4 components, column major, OpenGL style, right handed
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
370 typedef struct Matrix {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
371 float m0, m4, m8, m12; // Matrix first row (4 components)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
372 float m1, m5, m9, m13; // Matrix second row (4 components)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
373 float m2, m6, m10, m14; // Matrix third row (4 components)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
374 float m3, m7, m11, m15; // Matrix fourth row (4 components)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
375 } Matrix;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
376 #define RL_MATRIX_TYPE
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
377 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
378
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
379 // Dynamic vertex buffers (position + texcoords + colors + indices arrays)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
380 typedef struct rlVertexBuffer {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
381 int elementCount; // Number of elements in the buffer (QUADS)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
382
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
383 float *vertices; // Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
384 float *texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
385 float *normals; // Vertex normal (XYZ - 3 components per vertex) (shader-location = 2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
386 unsigned char *colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
387 #if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
388 unsigned int *indices; // Vertex indices (in case vertex data comes indexed) (6 indices per quad)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
389 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
390 #if defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
391 unsigned short *indices; // Vertex indices (in case vertex data comes indexed) (6 indices per quad)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
392 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
393 unsigned int vaoId; // OpenGL Vertex Array Object id
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
394 unsigned int vboId[5]; // OpenGL Vertex Buffer Objects id (5 types of vertex data)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
395 } rlVertexBuffer;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
396
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
397 // Draw call type
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
398 // NOTE: Only texture changes register a new draw, other state-change-related elements are not
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
399 // used at this moment (vaoId, shaderId, matrices), raylib forces a batch draw call if any
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
400 // of those state-change happens (this is done in core module)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
401 typedef struct rlDrawCall {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
402 int mode; // Drawing mode: LINES, TRIANGLES, QUADS
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
403 int vertexCount; // Number of vertex of the draw
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
404 int vertexAlignment; // Number of vertex required for index alignment (LINES, TRIANGLES)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
405 //unsigned int vaoId; // Vertex array id to be used on the draw -> Using RLGL.currentBatch->vertexBuffer.vaoId
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
406 //unsigned int shaderId; // Shader id to be used on the draw -> Using RLGL.currentShaderId
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
407 unsigned int textureId; // Texture id to be used on the draw -> Use to create new draw call if changes
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
408
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
409 //Matrix projection; // Projection matrix for this draw -> Using RLGL.projection by default
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
410 //Matrix modelview; // Modelview matrix for this draw -> Using RLGL.modelview by default
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
411 } rlDrawCall;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
412
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
413 // rlRenderBatch type
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
414 typedef struct rlRenderBatch {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
415 int bufferCount; // Number of vertex buffers (multi-buffering support)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
416 int currentBuffer; // Current buffer tracking in case of multi-buffering
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
417 rlVertexBuffer *vertexBuffer; // Dynamic buffer(s) for vertex data
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
418
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
419 rlDrawCall *draws; // Draw calls array, depends on textureId
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
420 int drawCounter; // Draw calls counter
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
421 float currentDepth; // Current depth value for next draw
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
422 } rlRenderBatch;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
423
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
424 // OpenGL version
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
425 typedef enum {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
426 RL_OPENGL_SOFTWARE = 0, // Software rendering
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
427 RL_OPENGL_11, // OpenGL 1.1
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
428 RL_OPENGL_21, // OpenGL 2.1 (GLSL 120)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
429 RL_OPENGL_33, // OpenGL 3.3 (GLSL 330)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
430 RL_OPENGL_43, // OpenGL 4.3 (using GLSL 330)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
431 RL_OPENGL_ES_20, // OpenGL ES 2.0 (GLSL 100)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
432 RL_OPENGL_ES_30 // OpenGL ES 3.0 (GLSL 300 es)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
433 } rlGlVersion;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
434
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
435 // Trace log level
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
436 // NOTE: Organized by priority level
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
437 typedef enum {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
438 RL_LOG_ALL = 0, // Display all logs
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
439 RL_LOG_TRACE, // Trace logging, intended for internal use only
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
441 RL_LOG_INFO, // Info logging, used for program execution info
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
442 RL_LOG_WARNING, // Warning logging, used on recoverable failures
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
443 RL_LOG_ERROR, // Error logging, used on unrecoverable failures
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
444 RL_LOG_FATAL, // Fatal logging, used to abort program: exit(EXIT_FAILURE)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
445 RL_LOG_NONE // Disable logging
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
446 } rlTraceLogLevel;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
447
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
448 // Texture pixel formats
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
449 // NOTE: Support depends on OpenGL version
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
450 typedef enum {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
451 RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
452 RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA, // 8*2 bpp (2 channels)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
453 RL_PIXELFORMAT_UNCOMPRESSED_R5G6B5, // 16 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
454 RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8, // 24 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
455 RL_PIXELFORMAT_UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
456 RL_PIXELFORMAT_UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
457 RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, // 32 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
458 RL_PIXELFORMAT_UNCOMPRESSED_R32, // 32 bpp (1 channel - float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
459 RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
460 RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
461 RL_PIXELFORMAT_UNCOMPRESSED_R16, // 16 bpp (1 channel - half float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
462 RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16, // 16*3 bpp (3 channels - half float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
463 RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16, // 16*4 bpp (4 channels - half float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
464 RL_PIXELFORMAT_COMPRESSED_DXT1_RGB, // 4 bpp (no alpha)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
465 RL_PIXELFORMAT_COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
466 RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA, // 8 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
467 RL_PIXELFORMAT_COMPRESSED_DXT5_RGBA, // 8 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
468 RL_PIXELFORMAT_COMPRESSED_ETC1_RGB, // 4 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
469 RL_PIXELFORMAT_COMPRESSED_ETC2_RGB, // 4 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
470 RL_PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA, // 8 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
471 RL_PIXELFORMAT_COMPRESSED_PVRT_RGB, // 4 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
472 RL_PIXELFORMAT_COMPRESSED_PVRT_RGBA, // 4 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
473 RL_PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA, // 8 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
474 RL_PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA // 2 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
475 } rlPixelFormat;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
476
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
477 // Texture parameters: filter mode
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
478 // NOTE 1: Filtering considers mipmaps if available in the texture
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
479 // NOTE 2: Filter is accordingly set for minification and magnification
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
480 typedef enum {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
481 RL_TEXTURE_FILTER_POINT = 0, // No filter, pixel approximation
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
482 RL_TEXTURE_FILTER_BILINEAR, // Linear filtering
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
483 RL_TEXTURE_FILTER_TRILINEAR, // Trilinear filtering (linear with mipmaps)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
484 RL_TEXTURE_FILTER_ANISOTROPIC_4X, // Anisotropic filtering 4x
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
485 RL_TEXTURE_FILTER_ANISOTROPIC_8X, // Anisotropic filtering 8x
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
486 RL_TEXTURE_FILTER_ANISOTROPIC_16X, // Anisotropic filtering 16x
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
487 } rlTextureFilter;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
488
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
489 // Color blending modes (pre-defined)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
490 typedef enum {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
491 RL_BLEND_ALPHA = 0, // Blend textures considering alpha (default)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
492 RL_BLEND_ADDITIVE, // Blend textures adding colors
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
493 RL_BLEND_MULTIPLIED, // Blend textures multiplying colors
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
494 RL_BLEND_ADD_COLORS, // Blend textures adding colors (alternative)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
495 RL_BLEND_SUBTRACT_COLORS, // Blend textures subtracting colors (alternative)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
496 RL_BLEND_ALPHA_PREMULTIPLY, // Blend premultiplied textures considering alpha
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
497 RL_BLEND_CUSTOM, // Blend textures using custom src/dst factors (use rlSetBlendFactors())
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
498 RL_BLEND_CUSTOM_SEPARATE // Blend textures using custom src/dst factors (use rlSetBlendFactorsSeparate())
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
499 } rlBlendMode;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
500
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
501 // Shader location point type
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
502 typedef enum {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
503 RL_SHADER_LOC_VERTEX_POSITION = 0, // Shader location: vertex attribute: position
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
504 RL_SHADER_LOC_VERTEX_TEXCOORD01, // Shader location: vertex attribute: texcoord01
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
505 RL_SHADER_LOC_VERTEX_TEXCOORD02, // Shader location: vertex attribute: texcoord02
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
506 RL_SHADER_LOC_VERTEX_NORMAL, // Shader location: vertex attribute: normal
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
507 RL_SHADER_LOC_VERTEX_TANGENT, // Shader location: vertex attribute: tangent
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
508 RL_SHADER_LOC_VERTEX_COLOR, // Shader location: vertex attribute: color
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
509 RL_SHADER_LOC_MATRIX_MVP, // Shader location: matrix uniform: model-view-projection
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
510 RL_SHADER_LOC_MATRIX_VIEW, // Shader location: matrix uniform: view (camera transform)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
511 RL_SHADER_LOC_MATRIX_PROJECTION, // Shader location: matrix uniform: projection
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
512 RL_SHADER_LOC_MATRIX_MODEL, // Shader location: matrix uniform: model (transform)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
513 RL_SHADER_LOC_MATRIX_NORMAL, // Shader location: matrix uniform: normal
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
514 RL_SHADER_LOC_VECTOR_VIEW, // Shader location: vector uniform: view
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
515 RL_SHADER_LOC_COLOR_DIFFUSE, // Shader location: vector uniform: diffuse color
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
516 RL_SHADER_LOC_COLOR_SPECULAR, // Shader location: vector uniform: specular color
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
517 RL_SHADER_LOC_COLOR_AMBIENT, // Shader location: vector uniform: ambient color
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
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)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
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)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
520 RL_SHADER_LOC_MAP_NORMAL, // Shader location: sampler2d texture: normal
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
521 RL_SHADER_LOC_MAP_ROUGHNESS, // Shader location: sampler2d texture: roughness
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
522 RL_SHADER_LOC_MAP_OCCLUSION, // Shader location: sampler2d texture: occlusion
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
523 RL_SHADER_LOC_MAP_EMISSION, // Shader location: sampler2d texture: emission
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
524 RL_SHADER_LOC_MAP_HEIGHT, // Shader location: sampler2d texture: height
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
525 RL_SHADER_LOC_MAP_CUBEMAP, // Shader location: samplerCube texture: cubemap
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
526 RL_SHADER_LOC_MAP_IRRADIANCE, // Shader location: samplerCube texture: irradiance
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
527 RL_SHADER_LOC_MAP_PREFILTER, // Shader location: samplerCube texture: prefilter
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
528 RL_SHADER_LOC_MAP_BRDF // Shader location: sampler2d texture: brdf
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
529 } rlShaderLocationIndex;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
530
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
531 #define RL_SHADER_LOC_MAP_DIFFUSE RL_SHADER_LOC_MAP_ALBEDO
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
532 #define RL_SHADER_LOC_MAP_SPECULAR RL_SHADER_LOC_MAP_METALNESS
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
533
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
534 // Shader uniform data type
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
535 typedef enum {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
536 RL_SHADER_UNIFORM_FLOAT = 0, // Shader uniform type: float
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
537 RL_SHADER_UNIFORM_VEC2, // Shader uniform type: vec2 (2 float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
538 RL_SHADER_UNIFORM_VEC3, // Shader uniform type: vec3 (3 float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
539 RL_SHADER_UNIFORM_VEC4, // Shader uniform type: vec4 (4 float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
540 RL_SHADER_UNIFORM_INT, // Shader uniform type: int
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
541 RL_SHADER_UNIFORM_IVEC2, // Shader uniform type: ivec2 (2 int)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
542 RL_SHADER_UNIFORM_IVEC3, // Shader uniform type: ivec3 (3 int)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
543 RL_SHADER_UNIFORM_IVEC4, // Shader uniform type: ivec4 (4 int)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
544 RL_SHADER_UNIFORM_UINT, // Shader uniform type: unsigned int
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
545 RL_SHADER_UNIFORM_UIVEC2, // Shader uniform type: uivec2 (2 unsigned int)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
546 RL_SHADER_UNIFORM_UIVEC3, // Shader uniform type: uivec3 (3 unsigned int)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
547 RL_SHADER_UNIFORM_UIVEC4, // Shader uniform type: uivec4 (4 unsigned int)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
548 RL_SHADER_UNIFORM_SAMPLER2D // Shader uniform type: sampler2d
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
549 } rlShaderUniformDataType;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
550
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
551 // Shader attribute data types
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
552 typedef enum {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
553 RL_SHADER_ATTRIB_FLOAT = 0, // Shader attribute type: float
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
554 RL_SHADER_ATTRIB_VEC2, // Shader attribute type: vec2 (2 float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
555 RL_SHADER_ATTRIB_VEC3, // Shader attribute type: vec3 (3 float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
556 RL_SHADER_ATTRIB_VEC4 // Shader attribute type: vec4 (4 float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
557 } rlShaderAttributeDataType;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
558
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
559 // Framebuffer attachment type
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
560 // NOTE: By default up to 8 color channels defined, but it can be more
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
561 typedef enum {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
562 RL_ATTACHMENT_COLOR_CHANNEL0 = 0, // Framebuffer attachment type: color 0
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
563 RL_ATTACHMENT_COLOR_CHANNEL1 = 1, // Framebuffer attachment type: color 1
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
564 RL_ATTACHMENT_COLOR_CHANNEL2 = 2, // Framebuffer attachment type: color 2
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
565 RL_ATTACHMENT_COLOR_CHANNEL3 = 3, // Framebuffer attachment type: color 3
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
566 RL_ATTACHMENT_COLOR_CHANNEL4 = 4, // Framebuffer attachment type: color 4
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
567 RL_ATTACHMENT_COLOR_CHANNEL5 = 5, // Framebuffer attachment type: color 5
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
568 RL_ATTACHMENT_COLOR_CHANNEL6 = 6, // Framebuffer attachment type: color 6
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
569 RL_ATTACHMENT_COLOR_CHANNEL7 = 7, // Framebuffer attachment type: color 7
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
570 RL_ATTACHMENT_DEPTH = 100, // Framebuffer attachment type: depth
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
571 RL_ATTACHMENT_STENCIL = 200, // Framebuffer attachment type: stencil
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
572 } rlFramebufferAttachType;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
573
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
574 // Framebuffer texture attachment type
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
575 typedef enum {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
576 RL_ATTACHMENT_CUBEMAP_POSITIVE_X = 0, // Framebuffer texture attachment type: cubemap, +X side
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
577 RL_ATTACHMENT_CUBEMAP_NEGATIVE_X = 1, // Framebuffer texture attachment type: cubemap, -X side
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
578 RL_ATTACHMENT_CUBEMAP_POSITIVE_Y = 2, // Framebuffer texture attachment type: cubemap, +Y side
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
579 RL_ATTACHMENT_CUBEMAP_NEGATIVE_Y = 3, // Framebuffer texture attachment type: cubemap, -Y side
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
580 RL_ATTACHMENT_CUBEMAP_POSITIVE_Z = 4, // Framebuffer texture attachment type: cubemap, +Z side
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
581 RL_ATTACHMENT_CUBEMAP_NEGATIVE_Z = 5, // Framebuffer texture attachment type: cubemap, -Z side
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
582 RL_ATTACHMENT_TEXTURE2D = 100, // Framebuffer texture attachment type: texture2d
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
583 RL_ATTACHMENT_RENDERBUFFER = 200, // Framebuffer texture attachment type: renderbuffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
584 } rlFramebufferAttachTextureType;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
585
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
586 // Face culling mode
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
587 typedef enum {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
588 RL_CULL_FACE_FRONT = 0,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
589 RL_CULL_FACE_BACK
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
590 } rlCullMode;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
591
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
592 //------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
593 // Functions Declaration - Matrix operations
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
594 //------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
595
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
596 #if defined(__cplusplus)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
597 extern "C" { // Prevents name mangling of functions
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
598 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
599
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
600 RLAPI void rlMatrixMode(int mode); // Choose the current matrix to be transformed
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
601 RLAPI void rlPushMatrix(void); // Push the current matrix to stack
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
602 RLAPI void rlPopMatrix(void); // Pop latest inserted matrix from stack
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
603 RLAPI void rlLoadIdentity(void); // Reset current matrix to identity matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
607 RLAPI void rlMultMatrixf(const float *matf); // Multiply the current matrix by another matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
608 RLAPI void rlFrustum(double left, double right, double bottom, double top, double znear, double zfar);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
609 RLAPI void rlOrtho(double left, double right, double bottom, double top, double znear, double zfar);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
610 RLAPI void rlViewport(int x, int y, int width, int height); // Set the viewport area
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
611 RLAPI void rlSetClipPlanes(double nearPlane, double farPlane); // Set clip planes distances
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
612 RLAPI double rlGetCullDistanceNear(void); // Get cull plane distance near
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
613 RLAPI double rlGetCullDistanceFar(void); // Get cull plane distance far
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
614
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
615 //------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
616 // Functions Declaration - Vertex level operations
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
617 //------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
618 RLAPI void rlBegin(int mode); // Initialize drawing mode (how to organize vertex)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
619 RLAPI void rlEnd(void); // Finish vertex providing
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
620 RLAPI void rlVertex2i(int x, int y); // Define one vertex (position) - 2 int
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
621 RLAPI void rlVertex2f(float x, float y); // Define one vertex (position) - 2 float
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
622 RLAPI void rlVertex3f(float x, float y, float z); // Define one vertex (position) - 3 float
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
623 RLAPI void rlTexCoord2f(float x, float y); // Define one vertex (texture coordinate) - 2 float
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
624 RLAPI void rlNormal3f(float x, float y, float z); // Define one vertex (normal) - 3 float
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
626 RLAPI void rlColor3f(float x, float y, float z); // Define one vertex (color) - 3 float
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
628
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
629 //------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
630 // Functions Declaration - OpenGL style functions (common to 1.1, 3.3+, ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
631 // NOTE: This functions are used to completely abstract raylib code from OpenGL layer,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
632 // some of them are direct wrappers over OpenGL calls, some others are custom
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
633 //------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
634
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
635 // Vertex buffers state
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
636 RLAPI bool rlEnableVertexArray(unsigned int vaoId); // Enable vertex array (VAO, if supported)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
637 RLAPI void rlDisableVertexArray(void); // Disable vertex array (VAO, if supported)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
638 RLAPI void rlEnableVertexBuffer(unsigned int id); // Enable vertex buffer (VBO)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
639 RLAPI void rlDisableVertexBuffer(void); // Disable vertex buffer (VBO)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
640 RLAPI void rlEnableVertexBufferElement(unsigned int id); // Enable vertex buffer element (VBO element)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
641 RLAPI void rlDisableVertexBufferElement(void); // Disable vertex buffer element (VBO element)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
642 RLAPI void rlEnableVertexAttribute(unsigned int index); // Enable vertex attribute index
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
643 RLAPI void rlDisableVertexAttribute(unsigned int index); // Disable vertex attribute index
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
644 RLAPI void rlEnableStatePointer(int vertexAttribType, void *buffer); // Enable attribute state pointer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
645 RLAPI void rlDisableStatePointer(int vertexAttribType); // Disable attribute state pointer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
646
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
647 // Textures state
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
648 RLAPI void rlActiveTextureSlot(int slot); // Select and active a texture slot
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
649 RLAPI void rlEnableTexture(unsigned int id); // Enable texture
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
650 RLAPI void rlDisableTexture(void); // Disable texture
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
651 RLAPI void rlEnableTextureCubemap(unsigned int id); // Enable texture cubemap
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
652 RLAPI void rlDisableTextureCubemap(void); // Disable texture cubemap
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
653 RLAPI void rlTextureParameters(unsigned int id, int param, int value); // Set texture parameters (filter, wrap)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
654 RLAPI void rlCubemapParameters(unsigned int id, int param, int value); // Set cubemap parameters (filter, wrap)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
655
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
656 // Shader state
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
657 RLAPI void rlEnableShader(unsigned int id); // Enable shader program
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
658 RLAPI void rlDisableShader(void); // Disable shader program
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
659
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
660 // Framebuffer state
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
661 RLAPI void rlEnableFramebuffer(unsigned int id); // Enable render texture (fbo)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
662 RLAPI void rlDisableFramebuffer(void); // Disable render texture (fbo), return to default framebuffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
663 RLAPI unsigned int rlGetActiveFramebuffer(void); // Get the currently active render texture (fbo), 0 for default framebuffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
664 RLAPI void rlActiveDrawBuffers(int count); // Activate multiple draw color buffers
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
665 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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
666 RLAPI void rlBindFramebuffer(unsigned int target, unsigned int framebuffer); // Bind framebuffer (FBO)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
667
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
668 // General render state
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
669 RLAPI void rlEnableColorBlend(void); // Enable color blending
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
670 RLAPI void rlDisableColorBlend(void); // Disable color blending
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
671 RLAPI void rlEnableDepthTest(void); // Enable depth test
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
672 RLAPI void rlDisableDepthTest(void); // Disable depth test
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
673 RLAPI void rlEnableDepthMask(void); // Enable depth write
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
674 RLAPI void rlDisableDepthMask(void); // Disable depth write
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
675 RLAPI void rlEnableBackfaceCulling(void); // Enable backface culling
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
676 RLAPI void rlDisableBackfaceCulling(void); // Disable backface culling
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
677 RLAPI void rlColorMask(bool r, bool g, bool b, bool a); // Color mask control
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
678 RLAPI void rlSetCullFace(int mode); // Set face culling mode
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
679 RLAPI void rlEnableScissorTest(void); // Enable scissor test
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
680 RLAPI void rlDisableScissorTest(void); // Disable scissor test
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
681 RLAPI void rlScissor(int x, int y, int width, int height); // Scissor test
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
682 RLAPI void rlEnablePointMode(void); // Enable point mode
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
683 RLAPI void rlDisablePointMode(void); // Disable point mode
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
684 RLAPI void rlSetPointSize(float size); // Set the point drawing size
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
685 RLAPI float rlGetPointSize(void); // Get the point drawing size
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
686 RLAPI void rlEnableWireMode(void); // Enable wire mode
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
687 RLAPI void rlDisableWireMode(void); // Disable wire mode
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
688 RLAPI void rlSetLineWidth(float width); // Set the line drawing width
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
689 RLAPI float rlGetLineWidth(void); // Get the line drawing width
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
690 RLAPI void rlEnableSmoothLines(void); // Enable line aliasing
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
691 RLAPI void rlDisableSmoothLines(void); // Disable line aliasing
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
692 RLAPI void rlEnableStereoRender(void); // Enable stereo rendering
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
693 RLAPI void rlDisableStereoRender(void); // Disable stereo rendering
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
694 RLAPI bool rlIsStereoRenderEnabled(void); // Check if stereo render is enabled
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
695
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
696 RLAPI void rlClearColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a); // Clear color buffer with color
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
697 RLAPI void rlClearScreenBuffers(void); // Clear used screen buffers (color and depth)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
698 RLAPI void rlCheckErrors(void); // Check and log OpenGL error codes
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
699 RLAPI void rlSetBlendMode(int mode); // Set blending mode
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
700 RLAPI void rlSetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation); // Set blending mode factor and equation (using OpenGL factors)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
701 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)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
702
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
703 //------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
704 // Functions Declaration - rlgl functionality
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
705 //------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
706 // rlgl initialization functions
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
707 RLAPI void rlglInit(int width, int height); // Initialize rlgl (buffers, shaders, textures, states)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
708 RLAPI void rlglClose(void); // De-initialize rlgl (buffers, shaders, textures)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
709 RLAPI void rlLoadExtensions(void *loader); // Load OpenGL extensions (loader function required)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
710 RLAPI void *rlGetProcAddress(const char *procName); // Get OpenGL procedure address
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
711 RLAPI int rlGetVersion(void); // Get current OpenGL version
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
712 RLAPI void rlSetFramebufferWidth(int width); // Set current framebuffer width
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
713 RLAPI int rlGetFramebufferWidth(void); // Get default framebuffer width
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
714 RLAPI void rlSetFramebufferHeight(int height); // Set current framebuffer height
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
715 RLAPI int rlGetFramebufferHeight(void); // Get default framebuffer height
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
716
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
717 RLAPI unsigned int rlGetTextureIdDefault(void); // Get default texture id
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
718 RLAPI unsigned int rlGetShaderIdDefault(void); // Get default shader id
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
719 RLAPI int *rlGetShaderLocsDefault(void); // Get default shader locations
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
720
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
721 // Render batch management
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
722 // NOTE: rlgl provides a default render batch to behave like OpenGL 1.1 immediate mode
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
723 // but this render batch API is exposed in case of custom batches are required
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
724 RLAPI rlRenderBatch rlLoadRenderBatch(int numBuffers, int bufferElements); // Load a render batch system
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
725 RLAPI void rlUnloadRenderBatch(rlRenderBatch batch); // Unload render batch system
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
726 RLAPI void rlDrawRenderBatch(rlRenderBatch *batch); // Draw render batch data (Update->Draw->Reset)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
727 RLAPI void rlSetRenderBatchActive(rlRenderBatch *batch); // Set the active render batch for rlgl (NULL for default internal)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
728 RLAPI void rlDrawRenderBatchActive(void); // Update and draw internal render batch
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
729 RLAPI bool rlCheckRenderBatchLimit(int vCount); // Check internal buffer overflow for a given number of vertex
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
730
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
731 RLAPI void rlSetTexture(unsigned int id); // Set current texture for render batch and check buffers limits
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
732
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
733 //------------------------------------------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
734
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
735 // Vertex buffers management
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
736 RLAPI unsigned int rlLoadVertexArray(void); // Load vertex array (vao) if supported
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
737 RLAPI unsigned int rlLoadVertexBuffer(const void *buffer, int size, bool dynamic); // Load a vertex buffer object
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
738 RLAPI unsigned int rlLoadVertexBufferElement(const void *buffer, int size, bool dynamic); // Load vertex buffer elements object
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
739 RLAPI void rlUpdateVertexBuffer(unsigned int bufferId, const void *data, int dataSize, int offset); // Update vertex buffer object data on GPU buffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
740 RLAPI void rlUpdateVertexBufferElements(unsigned int id, const void *data, int dataSize, int offset); // Update vertex buffer elements data on GPU buffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
741 RLAPI void rlUnloadVertexArray(unsigned int vaoId); // Unload vertex array (vao)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
742 RLAPI void rlUnloadVertexBuffer(unsigned int vboId); // Unload vertex buffer object
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
743 RLAPI void rlSetVertexAttribute(unsigned int index, int compSize, int type, bool normalized, int stride, int offset); // Set vertex attribute data configuration
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
744 RLAPI void rlSetVertexAttributeDivisor(unsigned int index, int divisor); // Set vertex attribute data divisor
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
745 RLAPI void rlSetVertexAttributeDefault(int locIndex, const void *value, int attribType, int count); // Set vertex attribute default value, when attribute to provided
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
746 RLAPI void rlDrawVertexArray(int offset, int count); // Draw vertex array (currently active vao)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
747 RLAPI void rlDrawVertexArrayElements(int offset, int count, const void *buffer); // Draw vertex array elements
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
748 RLAPI void rlDrawVertexArrayInstanced(int offset, int count, int instances); // Draw vertex array (currently active vao) with instancing
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
749 RLAPI void rlDrawVertexArrayElementsInstanced(int offset, int count, const void *buffer, int instances); // Draw vertex array elements with instancing
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
750
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
751 // Textures management
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
752 RLAPI unsigned int rlLoadTexture(const void *data, int width, int height, int format, int mipmapCount); // Load texture data
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
753 RLAPI unsigned int rlLoadTextureDepth(int width, int height, bool useRenderBuffer); // Load depth texture/renderbuffer (to be attached to fbo)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
754 RLAPI unsigned int rlLoadTextureCubemap(const void *data, int size, int format, int mipmapCount); // Load texture cubemap data
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
755 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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
756 RLAPI void rlGetGlTextureFormats(int format, unsigned int *glInternalFormat, unsigned int *glFormat, unsigned int *glType); // Get OpenGL internal formats
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
757 RLAPI const char *rlGetPixelFormatName(unsigned int format); // Get name string for pixel format
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
758 RLAPI void rlUnloadTexture(unsigned int id); // Unload texture from GPU memory
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
759 RLAPI void rlGenTextureMipmaps(unsigned int id, int width, int height, int format, int *mipmaps); // Generate mipmap data for selected texture
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
760 RLAPI void *rlReadTexturePixels(unsigned int id, int width, int height, int format); // Read texture pixel data
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
761 RLAPI unsigned char *rlReadScreenPixels(int width, int height); // Read screen pixel data (color buffer)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
762
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
763 // Framebuffer management (fbo)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
764 RLAPI unsigned int rlLoadFramebuffer(void); // Load an empty framebuffer
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
765 RLAPI void rlFramebufferAttach(unsigned int id, unsigned int texId, int attachType, int texType, int mipLevel); // Attach texture/renderbuffer to a framebuffer
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
766 RLAPI bool rlFramebufferComplete(unsigned int id); // Verify framebuffer is complete
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
767 RLAPI void rlUnloadFramebuffer(unsigned int id); // Delete framebuffer from GPU
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
768 // WARNING: Copy and resize framebuffer functionality only defined for software backend
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
769 RLAPI void rlCopyFramebuffer(int x, int y, int width, int height, int format, void *pixels); // Copy framebuffer pixel data to internal buffer
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
770 RLAPI void rlResizeFramebuffer(int width, int height); // Resize internal framebuffer
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
771
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
772 // Shaders management
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
773 RLAPI unsigned int rlLoadShader(const char *code, int type); // Load (compile) shader and return shader id (type: RL_VERTEX_SHADER, RL_FRAGMENT_SHADER, RL_COMPUTE_SHADER)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
774 RLAPI unsigned int rlLoadShaderProgram(const char *vsCode, const char *fsCode); // Load shader from code strings
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
775 RLAPI unsigned int rlLoadShaderProgramEx(unsigned int vsId, unsigned int fsId); // Load shader program, using already loaded shader ids
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
776 RLAPI unsigned int rlLoadShaderProgramCompute(unsigned int csId); // Load compute shader program
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
777 RLAPI void rlUnloadShader(unsigned int id); // Unload shader, loaded with rlLoadShader()
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
778 RLAPI void rlUnloadShaderProgram(unsigned int id); // Unload shader program
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
779 RLAPI int rlGetLocationUniform(unsigned int id, const char *uniformName); // Get shader location uniform, requires shader program id
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
780 RLAPI int rlGetLocationAttrib(unsigned int id, const char *attribName); // Get shader location attribute, requires shader program id
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
781 RLAPI void rlSetUniform(int locIndex, const void *value, int uniformType, int count); // Set shader value uniform
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
782 RLAPI void rlSetUniformMatrix(int locIndex, Matrix mat); // Set shader value matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
783 RLAPI void rlSetUniformMatrices(int locIndex, const Matrix *mat, int count); // Set shader value matrices
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
784 RLAPI void rlSetUniformSampler(int locIndex, unsigned int textureId); // Set shader value sampler
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
785 RLAPI void rlSetShader(unsigned int id, int *locs); // Set shader currently active (id and locations)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
786
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
787 // Compute shader management
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
788 RLAPI void rlComputeShaderDispatch(unsigned int groupX, unsigned int groupY, unsigned int groupZ); // Dispatch compute shader (equivalent to *draw* for graphics pipeline)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
789
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
790 // Shader buffer storage object management (ssbo)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
791 RLAPI unsigned int rlLoadShaderBuffer(unsigned int size, const void *data, int usageHint); // Load shader storage buffer object (SSBO)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
792 RLAPI void rlUnloadShaderBuffer(unsigned int ssboId); // Unload shader storage buffer object (SSBO)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
793 RLAPI void rlUpdateShaderBuffer(unsigned int id, const void *data, unsigned int dataSize, unsigned int offset); // Update SSBO buffer data
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
794 RLAPI void rlBindShaderBuffer(unsigned int id, unsigned int index); // Bind SSBO buffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
795 RLAPI void rlReadShaderBuffer(unsigned int id, void *dest, unsigned int count, unsigned int offset); // Read SSBO buffer data (GPU->CPU)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
796 RLAPI void rlCopyShaderBuffer(unsigned int destId, unsigned int srcId, unsigned int destOffset, unsigned int srcOffset, unsigned int count); // Copy SSBO data between buffers
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
797 RLAPI unsigned int rlGetShaderBufferSize(unsigned int id); // Get SSBO buffer size
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
798
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
799 // Buffer management
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
800 RLAPI void rlBindImageTexture(unsigned int id, unsigned int index, int format, bool readonly); // Bind image texture
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
801
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
802 // Matrix state management
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
803 RLAPI Matrix rlGetMatrixModelview(void); // Get internal modelview matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
804 RLAPI Matrix rlGetMatrixProjection(void); // Get internal projection matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
805 RLAPI Matrix rlGetMatrixTransform(void); // Get internal accumulated transform matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
806 RLAPI Matrix rlGetMatrixProjectionStereo(int eye); // Get internal projection matrix for stereo render (selected eye)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
807 RLAPI Matrix rlGetMatrixViewOffsetStereo(int eye); // Get internal view offset matrix for stereo render (selected eye)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
808 RLAPI void rlSetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
809 RLAPI void rlSetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
810 RLAPI void rlSetMatrixProjectionStereo(Matrix right, Matrix left); // Set eyes projection matrices for stereo rendering
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
811 RLAPI void rlSetMatrixViewOffsetStereo(Matrix right, Matrix left); // Set eyes view offsets matrices for stereo rendering
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
812
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
813 // Quick and dirty cube/quad buffers load->draw->unload
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
814 RLAPI void rlLoadDrawCube(void); // Load and draw a cube
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
815 RLAPI void rlLoadDrawQuad(void); // Load and draw a quad
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
816
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
817 #if defined(__cplusplus)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
818 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
819 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
820
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
821 #endif // RLGL_H
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
822
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
823 /***********************************************************************************
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
824 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
825 * RLGL IMPLEMENTATION
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
826 *
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
827 ************************************************************************************/
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
828
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
829 #if defined(RLGL_IMPLEMENTATION)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
830
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
831 // Expose OpenGL functions from glad in raylib
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
832 #if defined(BUILD_LIBTYPE_SHARED)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
833 #define GLAD_API_CALL_EXPORT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
834 #define GLAD_API_CALL_EXPORT_BUILD
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
835 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
836
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
837 #if defined(GRAPHICS_API_OPENGL_11)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
838 #if defined(GRAPHICS_API_OPENGL_SOFTWARE)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
839 #define RLSW_IMPLEMENTATION
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
840 #define SW_MALLOC(sz) RL_MALLOC(sz)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
841 #define SW_CALLOC(n,sz) RL_CALLOC(n, sz)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
842 #define SW_REALLOC(ptr, newSz) RL_REALLOC(ptr, newSz)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
843 #define SW_FREE(ptr) RL_FREE(ptr)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
844 #include "external/rlsw.h" // OpenGL 1.1 software implementation
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
845 #else
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
846 #if defined(__APPLE__)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
847 #include <OpenGL/gl.h> // OpenGL 1.1 library for OSX
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
848 #include <OpenGL/glext.h> // OpenGL extensions library
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
849 #else
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
850 // APIENTRY for OpenGL function pointer declarations is required
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
851 #if !defined(APIENTRY)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
852 #if defined(_WIN32)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
853 #define APIENTRY __stdcall
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
854 #else
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
855 #define APIENTRY
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
856 #endif
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
857 #endif
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
858 // WINGDIAPI definition. Some Windows OpenGL headers need it
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
859 #if !defined(WINGDIAPI) && defined(_WIN32)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
860 #define WINGDIAPI __declspec(dllimport)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
861 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
862
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
863 #include <GL/gl.h> // OpenGL 1.1 library
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
864 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
865 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
866 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
867
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
868 #if defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
869 #define GLAD_MALLOC RL_MALLOC
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
870 #define GLAD_FREE RL_FREE
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
871
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
872 #define GLAD_GL_IMPLEMENTATION
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
873 #include "external/glad.h" // GLAD extensions loading library, includes OpenGL headers
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
874 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
875
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
876 #if defined(GRAPHICS_API_OPENGL_ES3)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
877 #include <GLES3/gl3.h> // OpenGL ES 3.0 library
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
878 #define GL_GLEXT_PROTOTYPES
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
879 #include <GLES2/gl2ext.h> // OpenGL ES 2.0 extensions library
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
880 #elif defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
881 // NOTE: OpenGL ES 2.0 can be enabled on Desktop platforms,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
882 // in that case, functions are loaded from a custom glad for OpenGL ES 2.0
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
883 // TODO: OpenGL ES 2.0 support shouldn't be platform-dependent, neither require GLAD
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
884 #if defined(PLATFORM_DESKTOP_GLFW) || defined(PLATFORM_DESKTOP_SDL)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
885 #define GLAD_GLES2_IMPLEMENTATION
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
886 #include "external/glad_gles2.h"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
887 #else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
888 #define GL_GLEXT_PROTOTYPES
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
889 //#include <EGL/egl.h> // EGL library -> not required, platform layer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
890 #include <GLES2/gl2.h> // OpenGL ES 2.0 library
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
891 #include <GLES2/gl2ext.h> // OpenGL ES 2.0 extensions library
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
892 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
893
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
894 // It seems OpenGL ES 2.0 instancing entry points are not defined on Raspberry Pi
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
895 // provided headers (despite being defined in official Khronos GLES2 headers)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
896 // TODO: Avoid raylib platform-dependent code on rlgl, it should be a completely portable library
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
897 #if defined(PLATFORM_DRM)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
898 typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
899 typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
900 typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISOREXTPROC) (GLuint index, GLuint divisor);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
901 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
902 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
903
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
904 #include <stdlib.h> // Required for: calloc(), free()
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
905 #include <string.h> // Required for: strcmp(), strlen() [Used in rlglInit(), on extensions loading]
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
906 #include <math.h> // Required for: sqrtf(), sinf(), cosf(), floor(), log()
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
907
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
908 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
909 // Defines and Macros
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
910 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
911 #ifndef PI
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
912 #define PI 3.14159265358979323846f
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
913 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
914 #ifndef DEG2RAD
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
915 #define DEG2RAD (PI/180.0f)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
916 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
917 #ifndef RAD2DEG
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
918 #define RAD2DEG (180.0f/PI)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
919 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
920
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
921 #ifndef GL_SHADING_LANGUAGE_VERSION
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
922 #define GL_SHADING_LANGUAGE_VERSION 0x8B8C
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
923 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
924
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
925 #ifndef GL_COMPRESSED_RGB_S3TC_DXT1_EXT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
926 #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
927 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
928 #ifndef GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
929 #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
930 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
931 #ifndef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
932 #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
933 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
934 #ifndef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
935 #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
936 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
937 #ifndef GL_ETC1_RGB8_OES
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
938 #define GL_ETC1_RGB8_OES 0x8D64
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
939 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
940 #ifndef GL_COMPRESSED_RGB8_ETC2
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
941 #define GL_COMPRESSED_RGB8_ETC2 0x9274
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
942 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
943 #ifndef GL_COMPRESSED_RGBA8_ETC2_EAC
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
944 #define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
945 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
946 #ifndef GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
947 #define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
948 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
949 #ifndef GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
950 #define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
951 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
952 #ifndef GL_COMPRESSED_RGBA_ASTC_4x4_KHR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
953 #define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93b0
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
954 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
955 #ifndef GL_COMPRESSED_RGBA_ASTC_8x8_KHR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
956 #define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93b7
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
957 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
958
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
959 #ifndef GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
960 #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
961 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
962 #ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
963 #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
964 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
965
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
966 #ifndef GL_PROGRAM_POINT_SIZE
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
967 #define GL_PROGRAM_POINT_SIZE 0x8642
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
968 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
969
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
970 #ifndef GL_LINE_WIDTH
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
971 #define GL_LINE_WIDTH 0x0B21
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
972 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
973
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
974 #if defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
975 #define GL_UNSIGNED_SHORT_5_6_5 0x8363
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
976 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
977 #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
978 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
979
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
980 #if defined(GRAPHICS_API_OPENGL_21)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
981 #define GL_LUMINANCE 0x1909
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
982 #define GL_LUMINANCE_ALPHA 0x190A
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
983 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
984
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
985 #if defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
986 #define glClearDepth glClearDepthf
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
987 #if !defined(GRAPHICS_API_OPENGL_ES3)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
988 #define GL_READ_FRAMEBUFFER GL_FRAMEBUFFER
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
989 #define GL_DRAW_FRAMEBUFFER GL_FRAMEBUFFER
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
990 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
991 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
992
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
993 // Default shader vertex attribute names to set location points
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
994 #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
995 #define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
996 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
997 #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
998 #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
999 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1000 #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1001 #define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1002 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1003 #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1004 #define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1005 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1006 #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1007 #define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1008 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1009 #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1010 #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1011 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1012 #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_BONEINDICES
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1013 #define RL_DEFAULT_SHADER_ATTRIB_NAME_BONEINDICES "vertexBoneIndices" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1014 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1015 #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1016 #define RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS "vertexBoneWeights" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1017 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1018
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1019 #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_INSTANCETRANSFORM
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1020 #define RL_DEFAULT_SHADER_ATTRIB_NAME_INSTANCETRANSFORM "instanceTransform" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCETRANSFORM
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1021 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1022
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1023 #ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_MVP
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1024 #define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1025 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1026 #ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1027 #define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1028 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1029 #ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1030 #define RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1031 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1032 #ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1033 #define RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1034 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1035 #ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1036 #define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1037 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1038 #ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1039 #define RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (base tint color, multiplied by texture color)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1040 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1041 #ifndef RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1042 #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1043 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1044 #ifndef RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1045 #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1046 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1047 #ifndef RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1048 #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1049 #endif
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1050 #ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_BONEMATRICES
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1051 #define RL_DEFAULT_SHADER_UNIFORM_NAME_BONEMATRICES "boneMatrices" // bone matrices (required for GPU skinning)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1052 #endif
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1053
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1054 //----------------------------------------------------------------------------------
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1055 // Module Types and Structures Definition
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1056 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1057 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1058
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1059 typedef void *(*rlglLoadProc)(const char *name); // OpenGL extension functions loader signature (same as GLADloadproc)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1060
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1061 typedef struct rlglData {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1062 rlRenderBatch *currentBatch; // Current render batch
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1063 rlRenderBatch defaultBatch; // Default internal render batch
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1064
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1065 rlglLoadProc loader; // OpenGL function loader
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1066
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1067 struct {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1068 int vertexCounter; // Current active render batch vertex counter (generic, used for all batches)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1069 float texcoordx, texcoordy; // Current active texture coordinate (added on glVertex*())
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1070 float normalx, normaly, normalz; // Current active normal (added on glVertex*())
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1071 unsigned char colorr, colorg, colorb, colora; // Current active color (added on glVertex*())
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1072
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1073 int currentMatrixMode; // Current matrix mode
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1074 Matrix *currentMatrix; // Current matrix pointer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1075 Matrix modelview; // Default modelview matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1076 Matrix projection; // Default projection matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1077 Matrix transform; // Transform matrix to be used with rlTranslate, rlRotate, rlScale
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1078 bool transformRequired; // Require transform matrix application to current draw-call vertex (if required)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1079 Matrix stack[RL_MAX_MATRIX_STACK_SIZE];// Matrix stack for push/pop
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1080 int stackCounter; // Matrix stack counter
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1081
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1082 unsigned int currentTextureId; // Current texture id to be used on glBegin
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1083 unsigned int defaultTextureId; // Default texture used on shapes/poly drawing (required by shader)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1084 unsigned int activeTextureId[RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS]; // Active texture ids to be enabled on batch drawing (0 active by default)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1085 unsigned int defaultVShaderId; // Default vertex shader id (used by default shader program)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1086 unsigned int defaultFShaderId; // Default fragment shader id (used by default shader program)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1087 unsigned int defaultShaderId; // Default shader program id, supports vertex color and diffuse texture
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1088 int *defaultShaderLocs; // Default shader locations pointer to be used on rendering
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1089 unsigned int currentShaderId; // Current shader id to be used on rendering (by default, defaultShaderId)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1090 int *currentShaderLocs; // Current shader locations pointer to be used on rendering (by default, defaultShaderLocs)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1091
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1092 bool stereoRender; // Stereo rendering flag
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1093 Matrix projectionStereo[2]; // VR stereo rendering eyes projection matrices
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1094 Matrix viewOffsetStereo[2]; // VR stereo rendering eyes view offset matrices
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1095
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1096 // Blending variables
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1097 int currentBlendMode; // Blending mode active
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1098 int glBlendSrcFactor; // Blending source factor
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1099 int glBlendDstFactor; // Blending destination factor
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1100 int glBlendEquation; // Blending equation
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1101 int glBlendSrcFactorRGB; // Blending source RGB factor
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1102 int glBlendDestFactorRGB; // Blending destination RGB factor
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1103 int glBlendSrcFactorAlpha; // Blending source alpha factor
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1104 int glBlendDestFactorAlpha; // Blending destination alpha factor
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1105 int glBlendEquationRGB; // Blending equation for RGB
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1106 int glBlendEquationAlpha; // Blending equation for alpha
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1107 bool glCustomBlendModeModified; // Custom blending factor and equation modification status
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1108
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1109 int framebufferWidth; // Current framebuffer width
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1110 int framebufferHeight; // Current framebuffer height
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1111
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1112 } State; // Renderer state
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1113 struct {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1114 bool vao; // VAO support (OpenGL ES2 could not support VAO extension) (GL_ARB_vertex_array_object)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1115 bool instancing; // Instancing supported (GL_ANGLE_instanced_arrays, GL_EXT_draw_instanced + GL_EXT_instanced_arrays)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1116 bool texNPOT; // NPOT textures full support (GL_ARB_texture_non_power_of_two, GL_OES_texture_npot)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1117 bool texDepth; // Depth textures supported (GL_ARB_depth_texture, GL_OES_depth_texture)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1118 bool texDepthWebGL; // Depth textures supported WebGL specific (GL_WEBGL_depth_texture)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1119 bool texFloat32; // float textures support (32 bit per channel) (GL_OES_texture_float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1120 bool texFloat16; // half float textures support (16 bit per channel) (GL_OES_texture_half_float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1121 bool texCompDXT; // DDS texture compression support (GL_EXT_texture_compression_s3tc, GL_WEBGL_compressed_texture_s3tc, GL_WEBKIT_WEBGL_compressed_texture_s3tc)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1122 bool texCompETC1; // ETC1 texture compression support (GL_OES_compressed_ETC1_RGB8_texture, GL_WEBGL_compressed_texture_etc1)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1123 bool texCompETC2; // ETC2/EAC texture compression support (GL_ARB_ES3_compatibility)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1124 bool texCompPVRT; // PVR texture compression support (GL_IMG_texture_compression_pvrtc)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1125 bool texCompASTC; // ASTC texture compression support (GL_KHR_texture_compression_astc_hdr, GL_KHR_texture_compression_astc_ldr)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1126 bool texMirrorClamp; // Clamp mirror wrap mode supported (GL_EXT_texture_mirror_clamp)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1127 bool texAnisoFilter; // Anisotropic texture filtering support (GL_EXT_texture_filter_anisotropic)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1128 bool computeShader; // Compute shaders support (GL_ARB_compute_shader)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1129 bool ssbo; // Shader storage buffer object support (GL_ARB_shader_storage_buffer_object)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1130
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1131 float maxAnisotropyLevel; // Maximum anisotropy level supported (minimum is 2.0f)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1132 int maxDepthBits; // Maximum bits for depth component
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1133
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1134 } ExtSupported; // Extensions supported flags
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1135 } rlglData;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1136
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1137 #endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1138
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1139 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1140 // Global Variables Definition
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1141 //----------------------------------------------------------------------------------
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1142 static bool isGpuReady = false;
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1143 static double rlCullDistanceNear = RL_CULL_DISTANCE_NEAR;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1144 static double rlCullDistanceFar = RL_CULL_DISTANCE_FAR;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1145
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1146 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1147 static rlglData RLGL = { 0 };
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1148 #endif
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1149
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1150 #if defined(GRAPHICS_API_OPENGL_ES2) && !defined(GRAPHICS_API_OPENGL_ES3)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1151 // VAO functions entry points
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1152 // NOTE: VAO functionality is exposed through extensions (OES)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1153 static PFNGLGENVERTEXARRAYSOESPROC glGenVertexArrays = NULL;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1154 static PFNGLBINDVERTEXARRAYOESPROC glBindVertexArray = NULL;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1155 static PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArrays = NULL;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1156
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1157 // Instancing functionality entry points
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1158 // NOTE: Instancing functionality could be available through extensions
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1159 static PFNGLDRAWARRAYSINSTANCEDEXTPROC glDrawArraysInstanced = NULL;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1160 static PFNGLDRAWELEMENTSINSTANCEDEXTPROC glDrawElementsInstanced = NULL;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1161 static PFNGLVERTEXATTRIBDIVISOREXTPROC glVertexAttribDivisor = NULL;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1162 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1163
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1164 //----------------------------------------------------------------------------------
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1165 // Module Functions Declaration
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1166 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1167 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1168 static void rlLoadShaderDefault(void); // Load default shader
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1169 static void rlUnloadShaderDefault(void); // Unload default shader
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1170 #if RLGL_SHOW_GL_DETAILS_INFO
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1171 static const char *rlGetCompressedFormatName(int format); // Get compressed format official GL identifier name
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1172 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1173 #endif
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1174
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1175 static int rlGetPixelDataSize(int width, int height, int format); // Get pixel data size in bytes (image or texture)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1176
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1177 static Matrix rlMatrixIdentity(void); // Get identity matrix
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1178 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1179 // Auxiliar matrix math functions
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1180 typedef struct rl_float16 { float v[16]; } rl_float16;
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1181 static rl_float16 rlMatrixToFloatV(Matrix mat); // Get float array of matrix data
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1182 #define rlMatrixToFloat(mat) (rlMatrixToFloatV(mat).v) // Get float vector for Matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1183 static Matrix rlMatrixMultiply(Matrix left, Matrix right); // Multiply two matrices
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1184 static Matrix rlMatrixTranspose(Matrix mat); // Transposes provided matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1185 static Matrix rlMatrixInvert(Matrix mat); // Invert provided matrix
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1186 #endif
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1187
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1188 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1189 // Module Functions Definition - Matrix operations
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1190 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1191
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1192 #if defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1193 // Fallback to OpenGL 1.1 function calls
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1194 //---------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1195 void rlMatrixMode(int mode)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1196 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1197 switch (mode)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1198 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1199 case RL_PROJECTION: glMatrixMode(GL_PROJECTION); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1200 case RL_MODELVIEW: glMatrixMode(GL_MODELVIEW); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1201 case RL_TEXTURE: glMatrixMode(GL_TEXTURE); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1202 default: break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1203 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1204 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1205
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1206 void rlFrustum(double left, double right, double bottom, double top, double znear, double zfar)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1207 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1208 glFrustum(left, right, bottom, top, znear, zfar);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1209 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1210
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1211 void rlOrtho(double left, double right, double bottom, double top, double znear, double zfar)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1212 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1213 glOrtho(left, right, bottom, top, znear, zfar);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1214 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1215
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1216 void rlPushMatrix(void) { glPushMatrix(); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1217 void rlPopMatrix(void) { glPopMatrix(); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1218 void rlLoadIdentity(void) { glLoadIdentity(); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1219 void rlTranslatef(float x, float y, float z) { glTranslatef(x, y, z); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1220 void rlRotatef(float angle, float x, float y, float z) { glRotatef(angle, x, y, z); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1221 void rlScalef(float x, float y, float z) { glScalef(x, y, z); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1222 void rlMultMatrixf(const float *matf) { glMultMatrixf(matf); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1223 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1224 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1225 // Choose the current matrix to be transformed
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1226 void rlMatrixMode(int mode)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1227 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1228 if (mode == RL_PROJECTION) RLGL.State.currentMatrix = &RLGL.State.projection;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1229 else if (mode == RL_MODELVIEW) RLGL.State.currentMatrix = &RLGL.State.modelview;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1230 //else if (mode == RL_TEXTURE) // Not supported
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1231
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1232 RLGL.State.currentMatrixMode = mode;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1233 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1234
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1235 // Push the current matrix into RLGL.State.stack
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1236 void rlPushMatrix(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1237 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1238 if (RLGL.State.stackCounter >= RL_MAX_MATRIX_STACK_SIZE) TRACELOG(RL_LOG_ERROR, "RLGL: Matrix stack overflow (RL_MAX_MATRIX_STACK_SIZE)");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1239
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1240 if (RLGL.State.currentMatrixMode == RL_MODELVIEW)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1241 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1242 RLGL.State.transformRequired = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1243 RLGL.State.currentMatrix = &RLGL.State.transform;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1244 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1245
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1246 RLGL.State.stack[RLGL.State.stackCounter] = *RLGL.State.currentMatrix;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1247 RLGL.State.stackCounter++;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1248 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1249
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1250 // Pop latest inserted matrix from RLGL.State.stack
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1251 void rlPopMatrix(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1252 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1253 if (RLGL.State.stackCounter > 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1254 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1255 Matrix mat = RLGL.State.stack[RLGL.State.stackCounter - 1];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1256 *RLGL.State.currentMatrix = mat;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1257 RLGL.State.stackCounter--;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1258 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1259
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1260 if ((RLGL.State.stackCounter == 0) && (RLGL.State.currentMatrixMode == RL_MODELVIEW))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1261 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1262 RLGL.State.currentMatrix = &RLGL.State.modelview;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1263 RLGL.State.transformRequired = false;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1264 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1265 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1266
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1267 // Reset current matrix to identity matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1268 void rlLoadIdentity(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1269 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1270 *RLGL.State.currentMatrix = rlMatrixIdentity();
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1271 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1272
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1273 // Multiply the current matrix by a translation matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1274 void rlTranslatef(float x, float y, float z)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1275 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1276 Matrix matTranslation = rlMatrixIdentity();
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1277
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1278 // Set translation component of matrix
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1279 matTranslation.m12 = x;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1280 matTranslation.m13 = y;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1281 matTranslation.m14 = z;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1282
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1283 // NOTE: Transposing matrix by multiplication order
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1284 *RLGL.State.currentMatrix = rlMatrixMultiply(matTranslation, *RLGL.State.currentMatrix);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1285 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1286
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1287 // Multiply the current matrix by a rotation matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1288 // NOTE: The provided angle must be in degrees
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1289 void rlRotatef(float angle, float x, float y, float z)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1290 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1291 Matrix matRotation = rlMatrixIdentity();
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1292
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1293 // Axis vector (x, y, z) normalization
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1294 float lengthSquared = x*x + y*y + z*z;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1295 if ((lengthSquared != 1.0f) && (lengthSquared != 0.0f))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1296 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1297 float inverseLength = 1.0f/sqrtf(lengthSquared);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1298 x *= inverseLength;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1299 y *= inverseLength;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1300 z *= inverseLength;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1301 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1302
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1303 // Rotation matrix generation
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1304 float sinres = sinf(DEG2RAD*angle);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1305 float cosres = cosf(DEG2RAD*angle);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1306 float t = 1.0f - cosres;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1307
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1308 matRotation.m0 = x*x*t + cosres;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1309 matRotation.m1 = y*x*t + z*sinres;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1310 matRotation.m2 = z*x*t - y*sinres;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1311 matRotation.m3 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1312
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1313 matRotation.m4 = x*y*t - z*sinres;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1314 matRotation.m5 = y*y*t + cosres;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1315 matRotation.m6 = z*y*t + x*sinres;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1316 matRotation.m7 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1317
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1318 matRotation.m8 = x*z*t + y*sinres;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1319 matRotation.m9 = y*z*t - x*sinres;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1320 matRotation.m10 = z*z*t + cosres;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1321 matRotation.m11 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1322
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1323 matRotation.m12 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1324 matRotation.m13 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1325 matRotation.m14 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1326 matRotation.m15 = 1.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1327
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1328 // NOTE: Transposing matrix by multiplication order
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1329 *RLGL.State.currentMatrix = rlMatrixMultiply(matRotation, *RLGL.State.currentMatrix);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1330 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1331
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1332 // Multiply the current matrix by a scaling matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1333 void rlScalef(float x, float y, float z)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1334 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1335 Matrix matScale = rlMatrixIdentity();
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1336
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1337 // Set scale component of matrix
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1338 matScale.m0 = x;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1339 matScale.m5 = y;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1340 matScale.m10 = z;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1341
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1342 // NOTE: Transposing matrix by multiplication order
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1343 *RLGL.State.currentMatrix = rlMatrixMultiply(matScale, *RLGL.State.currentMatrix);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1344 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1345
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1346 // Multiply the current matrix by another matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1347 void rlMultMatrixf(const float *matf)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1348 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1349 // Matrix creation from array
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1350 // Conversion from column-major to row-major memory order
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1351 Matrix mat = { matf[0], matf[4], matf[8], matf[12],
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1352 matf[1], matf[5], matf[9], matf[13],
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1353 matf[2], matf[6], matf[10], matf[14],
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1354 matf[3], matf[7], matf[11], matf[15] };
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1355
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1356 *RLGL.State.currentMatrix = rlMatrixMultiply(mat, *RLGL.State.currentMatrix);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1357 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1358
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1359 // Multiply the current matrix by a perspective matrix generated by parameters
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1360 void rlFrustum(double left, double right, double bottom, double top, double znear, double zfar)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1361 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1362 Matrix matFrustum = { 0 };
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1363
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1364 float rl = (float)(right - left);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1365 float tb = (float)(top - bottom);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1366 float fn = (float)(zfar - znear);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1367
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1368 matFrustum.m0 = ((float) znear*2.0f)/rl;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1369 matFrustum.m1 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1370 matFrustum.m2 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1371 matFrustum.m3 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1372
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1373 matFrustum.m4 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1374 matFrustum.m5 = ((float) znear*2.0f)/tb;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1375 matFrustum.m6 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1376 matFrustum.m7 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1377
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1378 matFrustum.m8 = ((float)right + (float)left)/rl;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1379 matFrustum.m9 = ((float)top + (float)bottom)/tb;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1380 matFrustum.m10 = -((float)zfar + (float)znear)/fn;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1381 matFrustum.m11 = -1.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1382
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1383 matFrustum.m12 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1384 matFrustum.m13 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1385 matFrustum.m14 = -((float)zfar*(float)znear*2.0f)/fn;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1386 matFrustum.m15 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1387
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1388 *RLGL.State.currentMatrix = rlMatrixMultiply(*RLGL.State.currentMatrix, matFrustum);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1389 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1390
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1391 // Multiply the current matrix by an orthographic matrix generated by parameters
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1392 void rlOrtho(double left, double right, double bottom, double top, double znear, double zfar)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1393 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1394 // NOTE: If left-right and top-botton values are equal it could create a division by zero,
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1395 // response to it is platform/compiler dependent
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1396 Matrix matOrtho = { 0 };
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1397
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1398 float rl = (float)(right - left);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1399 float tb = (float)(top - bottom);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1400 float fn = (float)(zfar - znear);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1401
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1402 matOrtho.m0 = 2.0f/rl;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1403 matOrtho.m1 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1404 matOrtho.m2 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1405 matOrtho.m3 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1406 matOrtho.m4 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1407 matOrtho.m5 = 2.0f/tb;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1408 matOrtho.m6 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1409 matOrtho.m7 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1410 matOrtho.m8 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1411 matOrtho.m9 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1412 matOrtho.m10 = -2.0f/fn;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1413 matOrtho.m11 = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1414 matOrtho.m12 = -((float)left + (float)right)/rl;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1415 matOrtho.m13 = -((float)top + (float)bottom)/tb;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1416 matOrtho.m14 = -((float)zfar + (float)znear)/fn;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1417 matOrtho.m15 = 1.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1418
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1419 *RLGL.State.currentMatrix = rlMatrixMultiply(*RLGL.State.currentMatrix, matOrtho);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1420 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1421 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1422
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1423 // Set the viewport area (transformation from normalized device coordinates to window coordinates)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1424 void rlViewport(int x, int y, int width, int height)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1425 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1426 glViewport(x, y, width, height);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1427 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1428
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1429 // Set clip planes distances
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1430 void rlSetClipPlanes(double nearPlane, double farPlane)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1431 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1432 rlCullDistanceNear = nearPlane;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1433 rlCullDistanceFar = farPlane;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1434 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1435
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1436 // Get cull plane distance near
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1437 double rlGetCullDistanceNear(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1438 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1439 return rlCullDistanceNear;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1440 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1441
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1442 // Get cull plane distance far
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1443 double rlGetCullDistanceFar(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1444 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1445 return rlCullDistanceFar;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1446 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1447
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1448 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1449 // Module Functions Definition - Vertex level operations
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1450 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1451 #if defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1452 // Fallback to OpenGL 1.1 function calls
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1453 //---------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1454 void rlBegin(int mode)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1455 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1456 switch (mode)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1457 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1458 case RL_LINES: glBegin(GL_LINES); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1459 case RL_TRIANGLES: glBegin(GL_TRIANGLES); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1460 case RL_QUADS: glBegin(GL_QUADS); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1461 default: break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1462 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1463 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1464
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1465 void rlEnd(void) { glEnd(); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1466 void rlVertex2i(int x, int y) { glVertex2i(x, y); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1467 void rlVertex2f(float x, float y) { glVertex2f(x, y); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1468 void rlVertex3f(float x, float y, float z) { glVertex3f(x, y, z); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1469 void rlTexCoord2f(float x, float y) { glTexCoord2f(x, y); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1470 void rlNormal3f(float x, float y, float z) { glNormal3f(x, y, z); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1471 void rlColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { glColor4ub(r, g, b, a); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1472 void rlColor3f(float x, float y, float z) { glColor3f(x, y, z); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1473 void rlColor4f(float x, float y, float z, float w) { glColor4f(x, y, z, w); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1474 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1475 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1476 // Initialize drawing mode (how to organize vertex)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1477 void rlBegin(int mode)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1478 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1479 // Draw mode can be RL_LINES, RL_TRIANGLES and RL_QUADS
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1480 // NOTE: In all three cases, vertex are accumulated over default internal vertex buffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1481 if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode != mode)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1482 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1483 if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount > 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1484 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1485 // Make sure current RLGL.currentBatch->draws[i].vertexCount is aligned a multiple of 4,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1486 // that way, following QUADS drawing will keep aligned with index processing
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1487 // It implies adding some extra alignment vertex at the end of the draw,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1488 // those vertex are not processed but they are considered as an additional offset
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1489 // for the next set of vertex to be drawn
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1490 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);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1491 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)));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1492 else RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1493
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1494 if (!rlCheckRenderBatchLimit(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1495 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1496 RLGL.State.vertexCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1497 RLGL.currentBatch->drawCounter++;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1498 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1499 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1500
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1501 if (RLGL.currentBatch->drawCounter >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1502
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1503 RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = mode;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1504 RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = RLGL.State.currentTextureId;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1505 RLGL.State.currentTextureId = RLGL.State.defaultTextureId;
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1506 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1507 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1508
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1509 // Finish vertex providing
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1510 void rlEnd(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1511 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1512 // NOTE: Depth increment is dependent on rlOrtho(): z-near and z-far values,
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1513 // as well as depth buffer bit-depth (16bit or 24bit or 32bit)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1514 // Correct increment formula would be: depthInc = (zfar - znear)/pow(2, bits)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1515 RLGL.currentBatch->currentDepth += (1.0f/20000.0f);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1516 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1517
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1518 // Define one vertex (position)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1519 // NOTE: Vertex position data is the basic information required for drawing
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1520 void rlVertex3f(float x, float y, float z)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1521 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1522 float tx = x;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1523 float ty = y;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1524 float tz = z;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1525
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1526 // Transform provided vector if required
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1527 if (RLGL.State.transformRequired)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1528 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1529 tx = RLGL.State.transform.m0*x + RLGL.State.transform.m4*y + RLGL.State.transform.m8*z + RLGL.State.transform.m12;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1530 ty = RLGL.State.transform.m1*x + RLGL.State.transform.m5*y + RLGL.State.transform.m9*z + RLGL.State.transform.m13;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1531 tz = RLGL.State.transform.m2*x + RLGL.State.transform.m6*y + RLGL.State.transform.m10*z + RLGL.State.transform.m14;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1532 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1533
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1534 // WARNING: Be careful with primitives breaking when launching a new batch!
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1535 // RL_LINES comes in pairs, RL_TRIANGLES come in groups of 3 vertices and RL_QUADS come in groups of 4 vertices
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1536 // Checking 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
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1537 if (RLGL.State.vertexCounter > (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4 - 4))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1538 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1539 if ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_LINES) &&
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1540 (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%2 == 0))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1541 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1542 // Reached the maximum number of vertices for RL_LINES drawing
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1543 // Launch a draw call but keep current state for next vertices comming
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1544 // NOTE: Adding +1 vertex to the check for some safety
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1545 rlCheckRenderBatchLimit(2 + 1);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1546 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1547 else if ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_TRIANGLES) &&
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1548 (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%3 == 0))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1549 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1550 rlCheckRenderBatchLimit(3 + 1);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1551 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1552 else if ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_QUADS) &&
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1553 (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4 == 0))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1554 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1555 rlCheckRenderBatchLimit(4 + 1);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1556 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1557 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1558
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1559 // Add vertices
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1560 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vertices[3*RLGL.State.vertexCounter] = tx;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1561 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vertices[3*RLGL.State.vertexCounter + 1] = ty;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1562 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vertices[3*RLGL.State.vertexCounter + 2] = tz;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1563
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1564 // Add current texcoord
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1565 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].texcoords[2*RLGL.State.vertexCounter] = RLGL.State.texcoordx;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1566 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].texcoords[2*RLGL.State.vertexCounter + 1] = RLGL.State.texcoordy;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1567
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1568 // Add current normal
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1569 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].normals[3*RLGL.State.vertexCounter] = RLGL.State.normalx;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1570 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].normals[3*RLGL.State.vertexCounter + 1] = RLGL.State.normaly;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1571 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].normals[3*RLGL.State.vertexCounter + 2] = RLGL.State.normalz;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1572
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1573 // Add current color
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1574 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].colors[4*RLGL.State.vertexCounter] = RLGL.State.colorr;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1575 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].colors[4*RLGL.State.vertexCounter + 1] = RLGL.State.colorg;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1576 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].colors[4*RLGL.State.vertexCounter + 2] = RLGL.State.colorb;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1577 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].colors[4*RLGL.State.vertexCounter + 3] = RLGL.State.colora;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1578
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1579 RLGL.State.vertexCounter++;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1580 RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount++;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1581 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1582
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1583 // Define one vertex (position)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1584 void rlVertex2f(float x, float y)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1585 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1586 rlVertex3f(x, y, RLGL.currentBatch->currentDepth);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1587 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1588
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1589 // Define one vertex (position)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1590 void rlVertex2i(int x, int y)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1591 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1592 rlVertex3f((float)x, (float)y, RLGL.currentBatch->currentDepth);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1593 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1594
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1595 // Define one vertex (texture coordinate)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1596 // NOTE: Texture coordinates are limited to QUADS only
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1597 void rlTexCoord2f(float x, float y)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1598 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1599 RLGL.State.texcoordx = x;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1600 RLGL.State.texcoordy = y;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1601 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1602
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1603 // Define one vertex (normal)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1604 // NOTE: Normals limited to TRIANGLES only?
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1605 void rlNormal3f(float x, float y, float z)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1606 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1607 float normalx = x;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1608 float normaly = y;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1609 float normalz = z;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1610 if (RLGL.State.transformRequired)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1611 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1612 normalx = RLGL.State.transform.m0*x + RLGL.State.transform.m4*y + RLGL.State.transform.m8*z;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1613 normaly = RLGL.State.transform.m1*x + RLGL.State.transform.m5*y + RLGL.State.transform.m9*z;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1614 normalz = RLGL.State.transform.m2*x + RLGL.State.transform.m6*y + RLGL.State.transform.m10*z;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1615 }
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1616
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1617 // NOTE: Default behavior assumes the normal vector is in the correct space for what the shader expects,
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1618 // it could be not normalized to 0.0f..1.0f, magnitud can be useed for some effects
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1619 /*
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1620 // WARNING: Vector normalization if required
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1621 float length = sqrtf(normalx*normalx + normaly*normaly + normalz*normalz);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1622 if (length != 0.0f)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1623 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1624 float ilength = 1.0f/length;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1625 normalx *= ilength;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1626 normaly *= ilength;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1627 normalz *= ilength;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1628 }
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1629 */
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1630 RLGL.State.normalx = normalx;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1631 RLGL.State.normaly = normaly;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1632 RLGL.State.normalz = normalz;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1633 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1634
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1635 // Define one vertex (color)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1636 void rlColor4ub(unsigned char x, unsigned char y, unsigned char z, unsigned char w)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1637 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1638 RLGL.State.colorr = x;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1639 RLGL.State.colorg = y;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1640 RLGL.State.colorb = z;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1641 RLGL.State.colora = w;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1642 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1643
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1644 // Define one vertex (color)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1645 void rlColor4f(float r, float g, float b, float a)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1646 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1647 rlColor4ub((unsigned char)(r*255), (unsigned char)(g*255), (unsigned char)(b*255), (unsigned char)(a*255));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1648 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1649
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1650 // Define one vertex (color)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1651 void rlColor3f(float x, float y, float z)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1652 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1653 rlColor4ub((unsigned char)(x*255), (unsigned char)(y*255), (unsigned char)(z*255), 255);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1654 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1655
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1656 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1657
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1658 //--------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1659 // Module Functions Definition - OpenGL style functions (common to 1.1, 3.3+, ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1660 //--------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1661
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1662 // Set current texture to use
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1663 void rlSetTexture(unsigned int id)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1664 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1665 if (id == 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1666 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1667 #if defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1668 rlDisableTexture();
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1669 #else
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1670 // NOTE: If quads batch limit is reached, force a draw call and next batch starts
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1671 if (RLGL.State.vertexCounter >=
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1672 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1673 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1674 rlDrawRenderBatch(RLGL.currentBatch);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1675 }
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1676 RLGL.State.currentTextureId = RLGL.State.defaultTextureId;
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1677 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1678 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1679 else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1680 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1681 #if defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1682 rlEnableTexture(id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1683 #else
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1684 RLGL.State.currentTextureId = id;
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1685 if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId != id)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1686 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1687 if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount > 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1688 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1689 // Make sure current RLGL.currentBatch->draws[i].vertexCount is aligned a multiple of 4,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1690 // that way, following QUADS drawing will keep aligned with index processing
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1691 // It implies adding some extra alignment vertex at the end of the draw,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1692 // those vertex are not processed but they are considered as an additional offset
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1693 // for the next set of vertex to be drawn
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1694 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);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1695 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)));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1696 else RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1697
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1698 if (!rlCheckRenderBatchLimit(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1699 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1700 RLGL.State.vertexCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1701
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1702 RLGL.currentBatch->drawCounter++;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1703
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1704 RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 2].mode;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1705
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1706 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1707 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1708
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1709 if (RLGL.currentBatch->drawCounter >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1710
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1711 RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = id;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1712 RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1713 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1714 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1715 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1716 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1717
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1718 // Select and active a texture slot
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1719 void rlActiveTextureSlot(int slot)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1720 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1721 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1722 glActiveTexture(GL_TEXTURE0 + slot);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1723 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1724 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1725
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1726 // Enable texture
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1727 void rlEnableTexture(unsigned int id)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1728 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1729 #if defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1730 glEnable(GL_TEXTURE_2D);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1731 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1732 glBindTexture(GL_TEXTURE_2D, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1733 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1734
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1735 // Disable texture
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1736 void rlDisableTexture(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1737 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1738 #if defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1739 glDisable(GL_TEXTURE_2D);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1740 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1741 glBindTexture(GL_TEXTURE_2D, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1742 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1743
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1744 // Enable texture cubemap
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1745 void rlEnableTextureCubemap(unsigned int id)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1746 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1747 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1748 glBindTexture(GL_TEXTURE_CUBE_MAP, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1749 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1750 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1751
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1752 // Disable texture cubemap
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1753 void rlDisableTextureCubemap(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1754 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1755 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1756 glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1757 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1758 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1759
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1760 // Set texture parameters (wrap mode/filter mode)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1761 void rlTextureParameters(unsigned int id, int param, int value)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1762 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1763 glBindTexture(GL_TEXTURE_2D, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1764
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1765 switch (param)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1766 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1767 case RL_TEXTURE_WRAP_S:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1768 case RL_TEXTURE_WRAP_T:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1769 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1770 if (value == RL_TEXTURE_WRAP_MIRROR_CLAMP)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1771 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1772 #if !defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1773 if (RLGL.ExtSupported.texMirrorClamp) glTexParameteri(GL_TEXTURE_2D, param, value);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1774 else TRACELOG(RL_LOG_WARNING, "GL: Clamp mirror wrap mode not supported (GL_MIRROR_CLAMP_EXT)");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1775 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1776 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1777 else glTexParameteri(GL_TEXTURE_2D, param, value);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1778 } break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1779 case RL_TEXTURE_MAG_FILTER:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1780 case RL_TEXTURE_MIN_FILTER: glTexParameteri(GL_TEXTURE_2D, param, value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1781 case RL_TEXTURE_FILTER_ANISOTROPIC:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1782 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1783 #if !defined(GRAPHICS_API_OPENGL_11)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1784 // Reset anisotropy filter, in case it was set
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1785 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1786
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1787 if (value <= RLGL.ExtSupported.maxAnisotropyLevel) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1788 else if (RLGL.ExtSupported.maxAnisotropyLevel > 0.0f)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1789 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1790 TRACELOG(RL_LOG_WARNING, "GL: Maximum anisotropic filter level supported is %iX", id, (int)RLGL.ExtSupported.maxAnisotropyLevel);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1791 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1792 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1793 else TRACELOG(RL_LOG_WARNING, "GL: Anisotropic filtering not supported");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1794 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1795 } break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1796 #if defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1797 case RL_TEXTURE_MIPMAP_BIAS_RATIO: glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, value/100.0f);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1798 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1799 default: break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1800 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1801
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1802 glBindTexture(GL_TEXTURE_2D, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1803 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1804
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1805 // Set cubemap parameters (wrap mode/filter mode)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1806 void rlCubemapParameters(unsigned int id, int param, int value)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1807 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1808 #if !defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1809 glBindTexture(GL_TEXTURE_CUBE_MAP, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1810
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1811 // Reset anisotropy filter, in case it was set
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1812 glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1813
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1814 switch (param)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1815 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1816 case RL_TEXTURE_WRAP_S:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1817 case RL_TEXTURE_WRAP_T:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1818 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1819 if (value == RL_TEXTURE_WRAP_MIRROR_CLAMP)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1820 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1821 if (RLGL.ExtSupported.texMirrorClamp) glTexParameteri(GL_TEXTURE_CUBE_MAP, param, value);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1822 else TRACELOG(RL_LOG_WARNING, "GL: Clamp mirror wrap mode not supported (GL_MIRROR_CLAMP_EXT)");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1823 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1824 else glTexParameteri(GL_TEXTURE_CUBE_MAP, param, value);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1825 } break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1826 case RL_TEXTURE_MAG_FILTER:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1827 case RL_TEXTURE_MIN_FILTER: glTexParameteri(GL_TEXTURE_CUBE_MAP, param, value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1828 case RL_TEXTURE_FILTER_ANISOTROPIC:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1829 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1830 if (value <= RLGL.ExtSupported.maxAnisotropyLevel) glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1831 else if (RLGL.ExtSupported.maxAnisotropyLevel > 0.0f)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1832 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1833 TRACELOG(RL_LOG_WARNING, "GL: Maximum anisotropic filter level supported is %iX", id, (int)RLGL.ExtSupported.maxAnisotropyLevel);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1834 glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1835 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1836 else TRACELOG(RL_LOG_WARNING, "GL: Anisotropic filtering not supported");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1837 } break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1838 #if defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1839 case RL_TEXTURE_MIPMAP_BIAS_RATIO: glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_LOD_BIAS, value/100.0f);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1840 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1841 default: break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1842 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1843
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1844 glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1845 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1846 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1847
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1848 // Enable shader program
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1849 void rlEnableShader(unsigned int id)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1850 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1851 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1852 glUseProgram(id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1853 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1854 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1855
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1856 // Disable shader program
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1857 void rlDisableShader(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1858 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1859 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1860 glUseProgram(0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1861 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1862 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1863
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1864 // Enable rendering to texture (fbo)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1865 void rlEnableFramebuffer(unsigned int id)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1866 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1867 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_SOFTWARE))
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1868 glBindFramebuffer(GL_FRAMEBUFFER, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1869 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1870 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1871
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1872 // return the active render texture (fbo)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1873 unsigned int rlGetActiveFramebuffer(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1874 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1875 GLint fboId = 0;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1876 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES3) || defined(GRAPHICS_API_OPENGL_SOFTWARE))
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1877 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &fboId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1878 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1879 return fboId;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1880 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1881
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1882 // Disable rendering to texture
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1883 void rlDisableFramebuffer(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1884 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1885 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_SOFTWARE))
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1886 glBindFramebuffer(GL_FRAMEBUFFER, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1887 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1888 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1889
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1890 // Blit active framebuffer to main framebuffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1891 void rlBlitFramebuffer(int srcX, int srcY, int srcWidth, int srcHeight, int dstX, int dstY, int dstWidth, int dstHeight, int bufferMask)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1892 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1893 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES3))
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1894 glBlitFramebuffer(srcX, srcY, srcWidth, srcHeight, dstX, dstY, dstWidth, dstHeight, bufferMask, GL_NEAREST);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1895 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1896 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1897
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1898 // Bind framebuffer object (fbo)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1899 void rlBindFramebuffer(unsigned int target, unsigned int framebuffer)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1900 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1901 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_SOFTWARE))
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1902 glBindFramebuffer(target, framebuffer);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1903 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1904 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1905
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1906 // Activate multiple draw color buffers
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1907 // NOTE: One color buffer is always active by default
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1908 void rlActiveDrawBuffers(int count)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1909 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1910 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES3))
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1911 // NOTE: Maximum number of draw buffers supported is implementation dependent,
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1912 // it can be queried with glGet*() but it must be at least 8
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1913 //GLint maxDrawBuffers = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1914 //glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1915
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1916 if (count > 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1917 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1918 if (count > 8) TRACELOG(RL_LOG_WARNING, "GL: Max color buffers limited to 8");
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1919 else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1920 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1921 unsigned int buffers[8] = {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1922 GL_COLOR_ATTACHMENT0,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1923 GL_COLOR_ATTACHMENT1,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1924 GL_COLOR_ATTACHMENT2,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1925 GL_COLOR_ATTACHMENT3,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1926 GL_COLOR_ATTACHMENT4,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1927 GL_COLOR_ATTACHMENT5,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1928 GL_COLOR_ATTACHMENT6,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1929 GL_COLOR_ATTACHMENT7,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1930 };
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1931
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1932 glDrawBuffers(count, buffers);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1933 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1934 }
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1935 else TRACELOG(RL_LOG_WARNING, "GL: One color buffer active by default");
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1936 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1937 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1938
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1939 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1940 // General render state configuration
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1941 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1942
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1943 // Enable color blending
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1944 void rlEnableColorBlend(void) { glEnable(GL_BLEND); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1945
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1946 // Disable color blending
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1947 void rlDisableColorBlend(void) { glDisable(GL_BLEND); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1948
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1949 // Enable depth test
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1950 void rlEnableDepthTest(void) { glEnable(GL_DEPTH_TEST); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1951
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1952 // Disable depth test
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1953 void rlDisableDepthTest(void) { glDisable(GL_DEPTH_TEST); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1954
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1955 // Enable depth write
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1956 void rlEnableDepthMask(void) { glDepthMask(GL_TRUE); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1957
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1958 // Disable depth write
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1959 void rlDisableDepthMask(void) { glDepthMask(GL_FALSE); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1960
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1961 // Enable backface culling
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1962 void rlEnableBackfaceCulling(void) { glEnable(GL_CULL_FACE); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1963
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1964 // Disable backface culling
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1965 void rlDisableBackfaceCulling(void) { glDisable(GL_CULL_FACE); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1966
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1967 // Set color mask active for screen read/draw
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1968 void rlColorMask(bool r, bool g, bool b, bool a) { glColorMask(r, g, b, a); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1969
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1970 // Set face culling mode
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1971 void rlSetCullFace(int mode)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1972 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1973 switch (mode)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1974 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1975 case RL_CULL_FACE_BACK: glCullFace(GL_BACK); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1976 case RL_CULL_FACE_FRONT: glCullFace(GL_FRONT); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1977 default: break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1978 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1979 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1980
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1981 // Enable scissor test
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1982 void rlEnableScissorTest(void) { glEnable(GL_SCISSOR_TEST); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1983
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1984 // Disable scissor test
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1985 void rlDisableScissorTest(void) { glDisable(GL_SCISSOR_TEST); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1986
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1987 // Scissor test
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1988 void rlScissor(int x, int y, int width, int height) { glScissor(x, y, width, height); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1989
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1990 // Enable wire mode
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1991 void rlEnableWireMode(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1992 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1993 #if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1994 // NOTE: glPolygonMode() not available on OpenGL ES
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1995 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1996 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1997 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1998
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
1999 // Disable wire mode
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2000 void rlDisableWireMode(void)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2001 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2002 #if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2003 // NOTE: glPolygonMode() not available on OpenGL ES
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2004 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2005 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2006 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2007
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2008 // Enable point mode
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2009 void rlEnablePointMode(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2010 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2011 #if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2012 // NOTE: glPolygonMode() not available on OpenGL ES
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2013 glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2014 glEnable(GL_PROGRAM_POINT_SIZE);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2015 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2016 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2017
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2018 // Disable point mode
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2019 void rlDisablePointMode(void)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2020 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2021 #if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2022 // NOTE: glPolygonMode() not available on OpenGL ES
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2023 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2024 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2025 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2026
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2027 // Set the line drawing width
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2028 void rlSetLineWidth(float width) { glLineWidth(width); }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2029
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2030 // Get the line drawing width
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2031 float rlGetLineWidth(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2032 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2033 float width = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2034 glGetFloatv(GL_LINE_WIDTH, &width);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2035 return width;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2036 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2037
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2038 // Set the point drawing size
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2039 void rlSetPointSize(float size)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2040 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2041 #if defined(GRAPHICS_API_OPENGL_11)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2042 glPointSize(size);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2043 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2044 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2045
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2046 // Get the point drawing size
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2047 float rlGetPointSize(void)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2048 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2049 float size = 1;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2050 #if defined(GRAPHICS_API_OPENGL_11)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2051 glGetFloatv(GL_POINT_SIZE, &size);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2052 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2053 return size;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2054
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2055 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2056
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2057 // Enable line aliasing
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2058 void rlEnableSmoothLines(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2059 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2060 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2061 glEnable(GL_LINE_SMOOTH);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2062 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2063 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2064
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2065 // Disable line aliasing
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2066 void rlDisableSmoothLines(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2067 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2068 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2069 glDisable(GL_LINE_SMOOTH);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2070 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2071 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2072
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2073 // Enable stereo rendering
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2074 void rlEnableStereoRender(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2075 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2076 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2077 RLGL.State.stereoRender = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2078 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2079 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2080
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2081 // Disable stereo rendering
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2082 void rlDisableStereoRender(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2083 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2084 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2085 RLGL.State.stereoRender = false;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2086 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2087 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2088
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2089 // Check if stereo render is enabled
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2090 bool rlIsStereoRenderEnabled(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2091 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2092 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2093 return RLGL.State.stereoRender;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2094 #else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2095 return false;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2096 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2097 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2098
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2099 // Clear color buffer with color
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2100 void rlClearColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2101 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2102 // Color values clamp to 0.0f(0) and 1.0f(255)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2103 float cr = (float)r/255;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2104 float cg = (float)g/255;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2105 float cb = (float)b/255;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2106 float ca = (float)a/255;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2107
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2108 glClearColor(cr, cg, cb, ca);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2109 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2110
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2111 // Clear used screen buffers (color and depth)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2112 void rlClearScreenBuffers(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2113 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2114 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear used buffers: Color and Depth (Depth is used for 3D)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2115 //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // Stencil buffer not used...
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2116 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2117
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2118 // Check and log OpenGL error codes
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2119 void rlCheckErrors(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2120 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2121 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2122 int check = 1;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2123 while (check)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2124 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2125 const GLenum err = glGetError();
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2126 switch (err)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2127 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2128 case GL_NO_ERROR: check = 0; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2129 case 0x0500: TRACELOG(RL_LOG_WARNING, "GL: Error detected: GL_INVALID_ENUM"); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2130 case 0x0501: TRACELOG(RL_LOG_WARNING, "GL: Error detected: GL_INVALID_VALUE"); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2131 case 0x0502: TRACELOG(RL_LOG_WARNING, "GL: Error detected: GL_INVALID_OPERATION"); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2132 case 0x0503: TRACELOG(RL_LOG_WARNING, "GL: Error detected: GL_STACK_OVERFLOW"); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2133 case 0x0504: TRACELOG(RL_LOG_WARNING, "GL: Error detected: GL_STACK_UNDERFLOW"); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2134 case 0x0505: TRACELOG(RL_LOG_WARNING, "GL: Error detected: GL_OUT_OF_MEMORY"); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2135 case 0x0506: TRACELOG(RL_LOG_WARNING, "GL: Error detected: GL_INVALID_FRAMEBUFFER_OPERATION"); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2136 default: TRACELOG(RL_LOG_WARNING, "GL: Error detected: Unknown error code: %x", err); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2137 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2138 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2139 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2140 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2141
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2142 // Set blend mode
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2143 void rlSetBlendMode(int mode)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2144 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2145 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2146 if ((RLGL.State.currentBlendMode != mode) || ((mode == RL_BLEND_CUSTOM || mode == RL_BLEND_CUSTOM_SEPARATE) && RLGL.State.glCustomBlendModeModified))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2147 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2148 rlDrawRenderBatch(RLGL.currentBatch);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2149
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2150 switch (mode)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2151 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2152 case RL_BLEND_ALPHA: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2153 case RL_BLEND_ADDITIVE: glBlendFunc(GL_SRC_ALPHA, GL_ONE); glBlendEquation(GL_FUNC_ADD); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2154 case RL_BLEND_MULTIPLIED: glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2155 case RL_BLEND_ADD_COLORS: glBlendFunc(GL_ONE, GL_ONE); glBlendEquation(GL_FUNC_ADD); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2156 case RL_BLEND_SUBTRACT_COLORS: glBlendFunc(GL_ONE, GL_ONE); glBlendEquation(GL_FUNC_SUBTRACT); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2157 case RL_BLEND_ALPHA_PREMULTIPLY: glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2158 case RL_BLEND_CUSTOM:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2159 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2160 // NOTE: Using GL blend src/dst factors and GL equation configured with rlSetBlendFactors()
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2161 glBlendFunc(RLGL.State.glBlendSrcFactor, RLGL.State.glBlendDstFactor); glBlendEquation(RLGL.State.glBlendEquation);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2162 } break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2163 case RL_BLEND_CUSTOM_SEPARATE:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2164 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2165 // NOTE: Using GL blend src/dst factors and GL equation configured with rlSetBlendFactorsSeparate()
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2166 glBlendFuncSeparate(RLGL.State.glBlendSrcFactorRGB, RLGL.State.glBlendDestFactorRGB, RLGL.State.glBlendSrcFactorAlpha, RLGL.State.glBlendDestFactorAlpha);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2167 glBlendEquationSeparate(RLGL.State.glBlendEquationRGB, RLGL.State.glBlendEquationAlpha);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2168 } break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2169 default: break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2170 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2171
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2172 RLGL.State.currentBlendMode = mode;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2173 RLGL.State.glCustomBlendModeModified = false;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2174 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2175 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2176 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2177
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2178 // Set blending mode factor and equation
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2179 void rlSetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2180 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2181 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2182 if ((RLGL.State.glBlendSrcFactor != glSrcFactor) ||
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2183 (RLGL.State.glBlendDstFactor != glDstFactor) ||
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2184 (RLGL.State.glBlendEquation != glEquation))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2185 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2186 RLGL.State.glBlendSrcFactor = glSrcFactor;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2187 RLGL.State.glBlendDstFactor = glDstFactor;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2188 RLGL.State.glBlendEquation = glEquation;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2189
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2190 RLGL.State.glCustomBlendModeModified = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2191 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2192 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2193 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2194
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2195 // Set blending mode factor and equation separately for RGB and alpha
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2196 void rlSetBlendFactorsSeparate(int glSrcRGB, int glDstRGB, int glSrcAlpha, int glDstAlpha, int glEqRGB, int glEqAlpha)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2197 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2198 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2199 if ((RLGL.State.glBlendSrcFactorRGB != glSrcRGB) ||
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2200 (RLGL.State.glBlendDestFactorRGB != glDstRGB) ||
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2201 (RLGL.State.glBlendSrcFactorAlpha != glSrcAlpha) ||
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2202 (RLGL.State.glBlendDestFactorAlpha != glDstAlpha) ||
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2203 (RLGL.State.glBlendEquationRGB != glEqRGB) ||
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2204 (RLGL.State.glBlendEquationAlpha != glEqAlpha))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2205 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2206 RLGL.State.glBlendSrcFactorRGB = glSrcRGB;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2207 RLGL.State.glBlendDestFactorRGB = glDstRGB;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2208 RLGL.State.glBlendSrcFactorAlpha = glSrcAlpha;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2209 RLGL.State.glBlendDestFactorAlpha = glDstAlpha;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2210 RLGL.State.glBlendEquationRGB = glEqRGB;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2211 RLGL.State.glBlendEquationAlpha = glEqAlpha;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2212
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2213 RLGL.State.glCustomBlendModeModified = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2214 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2215 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2216 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2217
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2218 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2219 // Module Functions Definition - OpenGL Debug
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2220 //----------------------------------------------------------------------------------
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2221 #if defined(GRAPHICS_API_OPENGL_43) && RLGL_ENABLE_OPENGL_DEBUG_CONTEXT
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2222 static void GLAPIENTRY rlDebugMessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2223 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2224 // Ignore non-significant error/warning codes (NVidia drivers)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2225 // NOTE: Here there are the details with a sample output:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2226 // - #131169 - Framebuffer detailed info: The driver allocated storage for renderbuffer 2. (severity: low)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2227 // - #131185 - Buffer detailed info: Buffer object 1 (bound to GL_ELEMENT_ARRAY_BUFFER_ARB, usage hint is GL_ENUM_88e4)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2228 // will use VIDEO memory as the source for buffer object operations. (severity: low)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2229 // - #131218 - Program/shader state performance warning: Vertex shader in program 7 is being recompiled based on GL state. (severity: medium)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2230 // - #131204 - Texture state usage warning: The texture object (0) bound to texture image unit 0 does not have
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2231 // a defined base level and cannot be used for texture mapping. (severity: low)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2232 if ((id == 131169) || (id == 131185) || (id == 131218) || (id == 131204)) return;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2233
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2234 const char *msgSource = NULL;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2235 switch (source)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2236 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2237 case GL_DEBUG_SOURCE_API: msgSource = "API"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2238 case GL_DEBUG_SOURCE_WINDOW_SYSTEM: msgSource = "WINDOW_SYSTEM"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2239 case GL_DEBUG_SOURCE_SHADER_COMPILER: msgSource = "SHADER_COMPILER"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2240 case GL_DEBUG_SOURCE_THIRD_PARTY: msgSource = "THIRD_PARTY"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2241 case GL_DEBUG_SOURCE_APPLICATION: msgSource = "APPLICATION"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2242 case GL_DEBUG_SOURCE_OTHER: msgSource = "OTHER"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2243 default: break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2244 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2245
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2246 const char *msgType = NULL;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2247 switch (type)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2248 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2249 case GL_DEBUG_TYPE_ERROR: msgType = "ERROR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2250 case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: msgType = "DEPRECATED_BEHAVIOR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2251 case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: msgType = "UNDEFINED_BEHAVIOR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2252 case GL_DEBUG_TYPE_PORTABILITY: msgType = "PORTABILITY"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2253 case GL_DEBUG_TYPE_PERFORMANCE: msgType = "PERFORMANCE"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2254 case GL_DEBUG_TYPE_MARKER: msgType = "MARKER"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2255 case GL_DEBUG_TYPE_PUSH_GROUP: msgType = "PUSH_GROUP"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2256 case GL_DEBUG_TYPE_POP_GROUP: msgType = "POP_GROUP"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2257 case GL_DEBUG_TYPE_OTHER: msgType = "OTHER"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2258 default: break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2259 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2260
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2261 const char *msgSeverity = "DEFAULT";
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2262 switch (severity)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2263 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2264 case GL_DEBUG_SEVERITY_LOW: msgSeverity = "LOW"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2265 case GL_DEBUG_SEVERITY_MEDIUM: msgSeverity = "MEDIUM"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2266 case GL_DEBUG_SEVERITY_HIGH: msgSeverity = "HIGH"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2267 case GL_DEBUG_SEVERITY_NOTIFICATION: msgSeverity = "NOTIFICATION"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2268 default: break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2269 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2270
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2271 TRACELOG(RL_LOG_WARNING, "GL: OpenGL debug message: %s", message);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2272 TRACELOG(RL_LOG_WARNING, " > Type: %s", msgType);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2273 TRACELOG(RL_LOG_WARNING, " > Source = %s", msgSource);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2274 TRACELOG(RL_LOG_WARNING, " > Severity = %s", msgSeverity);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2275 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2276 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2277
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2278 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2279 // Module Functions Definition - rlgl functionality
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2280 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2281
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2282 // Initialize rlgl: OpenGL extensions, default buffers/shaders/textures, OpenGL states
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2283 void rlglInit(int width, int height)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2284 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2285 isGpuReady = true;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2286
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2287 // Enable OpenGL debug context if requested (and supported)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2288 #if defined(GRAPHICS_API_OPENGL_43) && RLGL_ENABLE_OPENGL_DEBUG_CONTEXT
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2289 if ((glDebugMessageCallback != NULL) && (glDebugMessageControl != NULL))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2290 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2291 glDebugMessageCallback(rlDebugMessageCallback, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2292 // glDebugMessageControl(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, GL_DEBUG_SEVERITY_HIGH, 0, 0, GL_TRUE);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2293
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2294 // Debug context options:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2295 // - GL_DEBUG_OUTPUT - Faster version but not useful for breakpoints
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2296 // - 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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2297 glEnable(GL_DEBUG_OUTPUT);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2298 glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2299 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2300 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2301
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2302 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2303 // Init default white texture
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2304 unsigned char pixels[4] = { 255, 255, 255, 255 }; // 1 pixel RGBA (4 bytes)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2305 RLGL.State.defaultTextureId = rlLoadTexture(pixels, 1, 1, RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, 1);
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2306 RLGL.State.currentTextureId = RLGL.State.defaultTextureId;
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2307
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2308 if (RLGL.State.defaultTextureId != 0) TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Default texture loaded successfully", RLGL.State.defaultTextureId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2309 else TRACELOG(RL_LOG_WARNING, "TEXTURE: Failed to load default texture");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2310
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2311 // Init default Shader (customized for GL 3.3 and ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2312 // Loaded: RLGL.State.defaultShaderId + RLGL.State.defaultShaderLocs
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2313 rlLoadShaderDefault();
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2314 RLGL.State.currentShaderId = RLGL.State.defaultShaderId;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2315 RLGL.State.currentShaderLocs = RLGL.State.defaultShaderLocs;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2316
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2317 // Init default vertex arrays buffers
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2318 // Simulate that the default shader has the location RL_SHADER_LOC_VERTEX_NORMAL to bind the normal buffer for the default render batch
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2319 RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_NORMAL] = RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2320 RLGL.defaultBatch = rlLoadRenderBatch(RL_DEFAULT_BATCH_BUFFERS, RL_DEFAULT_BATCH_BUFFER_ELEMENTS);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2321 RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_NORMAL] = -1;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2322 RLGL.currentBatch = &RLGL.defaultBatch;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2323
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2324 // Init stack matrices (emulating OpenGL 1.1)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2325 for (int i = 0; i < RL_MAX_MATRIX_STACK_SIZE; i++) RLGL.State.stack[i] = rlMatrixIdentity();
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2326
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2327 // Init internal matrices
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2328 RLGL.State.transform = rlMatrixIdentity();
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2329 RLGL.State.projection = rlMatrixIdentity();
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2330 RLGL.State.modelview = rlMatrixIdentity();
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2331 RLGL.State.currentMatrix = &RLGL.State.modelview;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2332 #endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2333
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2334 #if defined(GRAPHICS_API_OPENGL_SOFTWARE)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2335 // Initialize software renderer backend
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2336 int result = swInit(width, height);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2337 if (result == 0)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2338 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2339 TRACELOG(RL_LOG_ERROR, "RLSW: Software renderer initialization failed!");
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2340 exit(-1);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2341 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2342 #endif
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2343
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2344 // Initialize OpenGL default states
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2345 //----------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2346 // Init state: Depth test
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2347 glDepthFunc(GL_LEQUAL); // Type of depth testing to apply
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2348 glDisable(GL_DEPTH_TEST); // Disable depth testing for 2D (only used for 3D)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2349
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2350 // Init state: Blending mode
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2351 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Color blending function (how colors are mixed)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2352 glEnable(GL_BLEND); // Enable color blending (required to work with transparencies)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2353
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2354 // Init state: Culling
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2355 // NOTE: All shapes/models triangles are drawn CCW
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2356 glCullFace(GL_BACK); // Cull the back face (default)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2357 glFrontFace(GL_CCW); // Front face are defined counter clockwise (default)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2358 glEnable(GL_CULL_FACE); // Enable backface culling
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2359
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2360 #if defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2361 // Init state: Color hints (deprecated in OpenGL 3.0+)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2362 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Improve quality of color and texture coordinate interpolation
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2363 glShadeModel(GL_SMOOTH); // Smooth shading between vertex (vertex colors interpolation)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2364 #endif
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2365 #if defined(GRAPHICS_API_OPENGL_33)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2366 // Init state: Cubemap seamless
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2367 glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); // Seamless cubemaps (not supported on OpenGL ES 2.0)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2368 #endif
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2369 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2370 // Store screen size into global variables
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2371 RLGL.State.framebufferWidth = width;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2372 RLGL.State.framebufferHeight = height;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2373 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2374
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2375 // Init state: Color/Depth buffers clear
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2376 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Set clear color (black)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2377 glClearDepth(1.0f); // Set clear depth value (default)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2378 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear color and depth buffers (depth buffer required for 3D)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2379
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2380 TRACELOG(RL_LOG_INFO, "RLGL: Default OpenGL state initialized successfully");
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2381 //----------------------------------------------------------
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2382 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2383
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2384 // Vertex Buffer Object deinitialization (memory free)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2385 void rlglClose(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2386 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2387 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2388 rlUnloadRenderBatch(RLGL.defaultBatch);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2389
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2390 rlUnloadShaderDefault(); // Unload default shader
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2391
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2392 glDeleteTextures(1, &RLGL.State.defaultTextureId); // Unload default texture
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2393 TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Default texture unloaded successfully", RLGL.State.defaultTextureId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2394 #endif
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2395
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2396 #if defined(GRAPHICS_API_OPENGL_SOFTWARE)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2397 swClose(); // Unload sofware renderer resources
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2398 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2399 isGpuReady = false;
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2400 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2401
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2402 // Load OpenGL extensions
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2403 // NOTE: External loader function must be provided
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2404 void rlLoadExtensions(void *loader)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2405 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2406 #if defined(GRAPHICS_API_OPENGL_33) // Also defined for GRAPHICS_API_OPENGL_21
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2407 // NOTE: glad is generated and contains only required OpenGL 3.3 Core extensions (and lower versions)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2408 if (gladLoadGL((GLADloadfunc)loader) == 0) TRACELOG(RL_LOG_WARNING, "GLAD: Cannot load OpenGL extensions");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2409 else TRACELOG(RL_LOG_INFO, "GLAD: OpenGL extensions loaded successfully");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2410
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2411 // Get number of supported extensions
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2412 GLint numExt = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2413 glGetIntegerv(GL_NUM_EXTENSIONS, &numExt);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2414 TRACELOG(RL_LOG_INFO, "GL: Supported extensions count: %i", numExt);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2415
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2416 #if RLGL_SHOW_GL_DETAILS_INFO
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2417 // Get supported extensions list
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2418 // WARNING: glGetStringi() not available on OpenGL 2.1
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2419 TRACELOG(RL_LOG_INFO, "GL: OpenGL extensions:");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2420 for (int i = 0; i < numExt; i++) TRACELOG(RL_LOG_INFO, " %s", glGetStringi(GL_EXTENSIONS, i));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2421 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2422
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2423 #if defined(GRAPHICS_API_OPENGL_21)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2424 // Register supported extensions flags
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2425 // Optional OpenGL 2.1 extensions
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2426 RLGL.ExtSupported.vao = GLAD_GL_ARB_vertex_array_object;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2427 RLGL.ExtSupported.instancing = (GLAD_GL_EXT_draw_instanced && GLAD_GL_ARB_instanced_arrays);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2428 RLGL.ExtSupported.texNPOT = GLAD_GL_ARB_texture_non_power_of_two;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2429 RLGL.ExtSupported.texFloat32 = GLAD_GL_ARB_texture_float;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2430 RLGL.ExtSupported.texFloat16 = GLAD_GL_ARB_texture_float;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2431 RLGL.ExtSupported.texDepth = GLAD_GL_ARB_depth_texture;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2432 RLGL.ExtSupported.maxDepthBits = 32;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2433 RLGL.ExtSupported.texAnisoFilter = GLAD_GL_EXT_texture_filter_anisotropic;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2434 RLGL.ExtSupported.texMirrorClamp = GLAD_GL_EXT_texture_mirror_clamp;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2435 #else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2436 // Register supported extensions flags
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2437 // OpenGL 3.3 extensions supported by default (core)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2438 RLGL.ExtSupported.vao = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2439 RLGL.ExtSupported.instancing = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2440 RLGL.ExtSupported.texNPOT = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2441 RLGL.ExtSupported.texFloat32 = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2442 RLGL.ExtSupported.texFloat16 = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2443 RLGL.ExtSupported.texDepth = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2444 RLGL.ExtSupported.maxDepthBits = 32;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2445 RLGL.ExtSupported.texAnisoFilter = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2446 RLGL.ExtSupported.texMirrorClamp = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2447 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2448
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2449 // Optional OpenGL 3.3 extensions
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2450 RLGL.ExtSupported.texCompASTC = GLAD_GL_KHR_texture_compression_astc_hdr && GLAD_GL_KHR_texture_compression_astc_ldr;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2451 RLGL.ExtSupported.texCompDXT = GLAD_GL_EXT_texture_compression_s3tc; // Texture compression: DXT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2452 RLGL.ExtSupported.texCompETC2 = GLAD_GL_ARB_ES3_compatibility; // Texture compression: ETC2/EAC
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2453 #if defined(GRAPHICS_API_OPENGL_43)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2454 RLGL.ExtSupported.computeShader = GLAD_GL_ARB_compute_shader;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2455 RLGL.ExtSupported.ssbo = GLAD_GL_ARB_shader_storage_buffer_object;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2456 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2457
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2458 #endif // GRAPHICS_API_OPENGL_33
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2459
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2460 #if defined(GRAPHICS_API_OPENGL_ES3)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2461 // Register supported extensions flags
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2462 // OpenGL ES 3.0 extensions supported by default (or it should be)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2463 RLGL.ExtSupported.vao = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2464 RLGL.ExtSupported.instancing = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2465 RLGL.ExtSupported.texNPOT = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2466 RLGL.ExtSupported.texFloat32 = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2467 RLGL.ExtSupported.texFloat16 = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2468 RLGL.ExtSupported.texDepth = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2469 RLGL.ExtSupported.texDepthWebGL = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2470 RLGL.ExtSupported.maxDepthBits = 24;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2471 RLGL.ExtSupported.texAnisoFilter = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2472 RLGL.ExtSupported.texMirrorClamp = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2473 // TODO: Check for additional OpenGL ES 3.0 supported extensions:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2474 //RLGL.ExtSupported.texCompDXT = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2475 //RLGL.ExtSupported.texCompETC1 = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2476 //RLGL.ExtSupported.texCompETC2 = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2477 //RLGL.ExtSupported.texCompPVRT = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2478 //RLGL.ExtSupported.texCompASTC = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2479 //RLGL.ExtSupported.maxAnisotropyLevel = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2480 //RLGL.ExtSupported.computeShader = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2481 //RLGL.ExtSupported.ssbo = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2482
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2483 #elif defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2484
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2485 #if defined(PLATFORM_DESKTOP_GLFW) || defined(PLATFORM_DESKTOP_SDL)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2486 // TODO: Support GLAD loader for OpenGL ES 3.0
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2487 if (gladLoadGLES2((GLADloadfunc)loader) == 0) TRACELOG(RL_LOG_WARNING, "GLAD: Cannot load OpenGL ES2.0 functions");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2488 else TRACELOG(RL_LOG_INFO, "GLAD: OpenGL ES 2.0 loaded successfully");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2489 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2490
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2491 // Get supported extensions list
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2492 GLint numExt = 0;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2493 const char **extList = (const char **)RL_CALLOC(512, sizeof(const char *)); // Allocate 512 strings pointers (2 KB)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2494 const char *extensions = (const char *)glGetString(GL_EXTENSIONS); // One big const string
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2495
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2496 // NOTE: String duplication rquired because glGetString() returns a const string
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2497 int extensionsLength = (int)strlen(extensions); // Get extensions string size in bytes
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2498 char *extensionsDup = (char *)RL_CALLOC(extensionsLength + 1, sizeof(char)); // Allocate space for copy with additional EOL byte
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2499 strncpy(extensionsDup, extensions, extensionsLength);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2500 extList[numExt] = extensionsDup;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2501
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2502 for (int i = 0; i < extensionsLength; i++)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2503 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2504 if (extensionsDup[i] == ' ')
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2505 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2506 extensionsDup[i] = '\0';
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2507 numExt++;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2508 extList[numExt] = &extensionsDup[i + 1];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2509 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2510 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2511
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2512 TRACELOG(RL_LOG_INFO, "GL: Supported extensions count: %i", numExt);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2513
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2514 #if RLGL_SHOW_GL_DETAILS_INFO
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2515 TRACELOG(RL_LOG_INFO, "GL: OpenGL extensions:");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2516 for (int i = 0; i < numExt; i++) TRACELOG(RL_LOG_INFO, " %s", extList[i]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2517 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2518
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2519 // Check required extensions
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2520 for (int i = 0; i < numExt; i++)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2521 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2522 // Check VAO support
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2523 // NOTE: Only check on OpenGL ES, OpenGL 3.3 has VAO support as core feature
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2524 if (strcmp(extList[i], (const char *)"GL_OES_vertex_array_object") == 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2525 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2526 // The extension is supported by our hardware and driver, try to get related functions pointers
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2527 // NOTE: emscripten does not support VAOs natively, it uses emulation and it reduces overall performance...
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2528 glGenVertexArrays = (PFNGLGENVERTEXARRAYSOESPROC)((rlglLoadProc)loader)("glGenVertexArraysOES");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2529 glBindVertexArray = (PFNGLBINDVERTEXARRAYOESPROC)((rlglLoadProc)loader)("glBindVertexArrayOES");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2530 glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSOESPROC)((rlglLoadProc)loader)("glDeleteVertexArraysOES");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2531 //glIsVertexArray = (PFNGLISVERTEXARRAYOESPROC)loader("glIsVertexArrayOES"); // NOTE: Fails in WebGL, omitted
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2532
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2533 if ((glGenVertexArrays != NULL) && (glBindVertexArray != NULL) && (glDeleteVertexArrays != NULL)) RLGL.ExtSupported.vao = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2534 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2535
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2536 // Check instanced rendering support
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2537 if (strstr(extList[i], (const char *)"instanced_arrays") != NULL) // Broad check for instanced_arrays
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2538 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2539 // Specific check
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2540 if (strcmp(extList[i], (const char *)"GL_ANGLE_instanced_arrays") == 0) // ANGLE
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2541 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2542 glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedANGLE");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2543 glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedANGLE");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2544 glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISOREXTPROC)((rlglLoadProc)loader)("glVertexAttribDivisorANGLE");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2545 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2546 else if (strcmp(extList[i], (const char *)"GL_EXT_instanced_arrays") == 0) // EXT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2547 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2548 glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedEXT");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2549 glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedEXT");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2550 glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISOREXTPROC)((rlglLoadProc)loader)("glVertexAttribDivisorEXT");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2551 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2552 else if (strcmp(extList[i], (const char *)"GL_NV_instanced_arrays") == 0) // NVIDIA GLES
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2553 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2554 glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedNV");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2555 glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedNV");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2556 glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISOREXTPROC)((rlglLoadProc)loader)("glVertexAttribDivisorNV");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2557 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2558
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2559 // The feature will only be marked as supported if the elements from GL_XXX_instanced_arrays are present
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2560 if ((glDrawArraysInstanced != NULL) && (glDrawElementsInstanced != NULL) && (glVertexAttribDivisor != NULL)) RLGL.ExtSupported.instancing = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2561 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2562 else if (strstr(extList[i], (const char *)"draw_instanced") != NULL)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2563 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2564 // GL_ANGLE_draw_instanced doesn't exist
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2565 if (strcmp(extList[i], (const char *)"GL_EXT_draw_instanced") == 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2566 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2567 glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedEXT");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2568 glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedEXT");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2569 }
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2570 else if (strcmp(extList[i], (const char *)"GL_NV_draw_instanced") == 0)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2571 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2572 glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedNV");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2573 glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedNV");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2574 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2575
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2576 // But the functions will at least be loaded if only GL_XX_EXT_draw_instanced exist
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2577 if ((glDrawArraysInstanced != NULL) && (glDrawElementsInstanced != NULL) && (glVertexAttribDivisor != NULL)) RLGL.ExtSupported.instancing = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2578 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2579
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2580 // Check NPOT textures support
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2581 // NOTE: Only check on OpenGL ES, OpenGL 3.3 has NPOT textures full support as core feature
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2582 if (strcmp(extList[i], (const char *)"GL_OES_texture_npot") == 0) RLGL.ExtSupported.texNPOT = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2583
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2584 // Check texture float support
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2585 if (strcmp(extList[i], (const char *)"GL_OES_texture_float") == 0) RLGL.ExtSupported.texFloat32 = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2586 if (strcmp(extList[i], (const char *)"GL_OES_texture_half_float") == 0) RLGL.ExtSupported.texFloat16 = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2587
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2588 // Check depth texture support
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2589 if (strcmp(extList[i], (const char *)"GL_OES_depth_texture") == 0) RLGL.ExtSupported.texDepth = true;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2590 if (strcmp(extList[i], (const char *)"GL_WEBGL_depth_texture") == 0) RLGL.ExtSupported.texDepthWebGL = true; // WebGL requires unsized internal format
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2591 if (RLGL.ExtSupported.texDepthWebGL) RLGL.ExtSupported.texDepth = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2592
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2593 if (strcmp(extList[i], (const char *)"GL_OES_depth24") == 0) RLGL.ExtSupported.maxDepthBits = 24; // Not available on WebGL
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2594 if (strcmp(extList[i], (const char *)"GL_OES_depth32") == 0) RLGL.ExtSupported.maxDepthBits = 32; // Not available on WebGL
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2595
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2596 // Check texture compression support: DXT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2597 if ((strcmp(extList[i], (const char *)"GL_EXT_texture_compression_s3tc") == 0) ||
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2598 (strcmp(extList[i], (const char *)"GL_WEBGL_compressed_texture_s3tc") == 0) ||
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2599 (strcmp(extList[i], (const char *)"GL_WEBKIT_WEBGL_compressed_texture_s3tc") == 0)) RLGL.ExtSupported.texCompDXT = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2600
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2601 // Check texture compression support: ETC1
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2602 if ((strcmp(extList[i], (const char *)"GL_OES_compressed_ETC1_RGB8_texture") == 0) ||
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2603 (strcmp(extList[i], (const char *)"GL_WEBGL_compressed_texture_etc1") == 0)) RLGL.ExtSupported.texCompETC1 = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2604
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2605 // Check texture compression support: ETC2/EAC
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2606 if (strcmp(extList[i], (const char *)"GL_ARB_ES3_compatibility") == 0) RLGL.ExtSupported.texCompETC2 = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2607
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2608 // Check texture compression support: PVR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2609 if (strcmp(extList[i], (const char *)"GL_IMG_texture_compression_pvrtc") == 0) RLGL.ExtSupported.texCompPVRT = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2610
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2611 // Check texture compression support: ASTC
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2612 if (strcmp(extList[i], (const char *)"GL_KHR_texture_compression_astc_hdr") == 0) RLGL.ExtSupported.texCompASTC = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2613
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2614 // Check anisotropic texture filter support
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2615 if (strcmp(extList[i], (const char *)"GL_EXT_texture_filter_anisotropic") == 0) RLGL.ExtSupported.texAnisoFilter = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2616
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2617 // Check clamp mirror wrap mode support
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2618 if (strcmp(extList[i], (const char *)"GL_EXT_texture_mirror_clamp") == 0) RLGL.ExtSupported.texMirrorClamp = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2619 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2620
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2621 // Free extensions pointers
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2622 RL_FREE(extList);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2623 RL_FREE(extensionsDup); // Duplicated string must be deallocated
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2624 #endif // GRAPHICS_API_OPENGL_ES2
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2625
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2626 // Check OpenGL information and capabilities
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2627 //------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2628 // Show current OpenGL and GLSL version
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2629 TRACELOG(RL_LOG_INFO, "GL: OpenGL device information:");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2630 TRACELOG(RL_LOG_INFO, " > Vendor: %s", glGetString(GL_VENDOR));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2631 TRACELOG(RL_LOG_INFO, " > Renderer: %s", glGetString(GL_RENDERER));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2632 TRACELOG(RL_LOG_INFO, " > Version: %s", glGetString(GL_VERSION));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2633 TRACELOG(RL_LOG_INFO, " > GLSL: %s", glGetString(GL_SHADING_LANGUAGE_VERSION));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2634
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2635 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2636 RLGL.loader = (rlglLoadProc)loader;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2637
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2638 // NOTE: Anisotropy levels capability is an extension
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2639 #ifndef GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2640 #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2641 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2642 glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &RLGL.ExtSupported.maxAnisotropyLevel);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2643
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2644 #if RLGL_SHOW_GL_DETAILS_INFO
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2645 // Show some OpenGL GPU capabilities
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2646 TRACELOG(RL_LOG_INFO, "GL: OpenGL capabilities:");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2647 GLint capability = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2648 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &capability);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2649 TRACELOG(RL_LOG_INFO, " GL_MAX_TEXTURE_SIZE: %i", capability);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2650 glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &capability);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2651 TRACELOG(RL_LOG_INFO, " GL_MAX_CUBE_MAP_TEXTURE_SIZE: %i", capability);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2652 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &capability);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2653 TRACELOG(RL_LOG_INFO, " GL_MAX_TEXTURE_IMAGE_UNITS: %i", capability);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2654 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &capability);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2655 TRACELOG(RL_LOG_INFO, " GL_MAX_VERTEX_ATTRIBS: %i", capability);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2656 #if !defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2657 glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &capability);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2658 TRACELOG(RL_LOG_INFO, " GL_MAX_UNIFORM_BLOCK_SIZE: %i", capability);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2659 glGetIntegerv(GL_MAX_DRAW_BUFFERS, &capability);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2660 TRACELOG(RL_LOG_INFO, " GL_MAX_DRAW_BUFFERS: %i", capability);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2661 if (RLGL.ExtSupported.texAnisoFilter) TRACELOG(RL_LOG_INFO, " GL_MAX_TEXTURE_MAX_ANISOTROPY: %.0f", RLGL.ExtSupported.maxAnisotropyLevel);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2662 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2663 glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &capability);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2664 TRACELOG(RL_LOG_INFO, " GL_NUM_COMPRESSED_TEXTURE_FORMATS: %i", capability);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2665 GLint *compFormats = (GLint *)RL_CALLOC(capability, sizeof(GLint));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2666 glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, compFormats);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2667 for (int i = 0; i < capability; i++) TRACELOG(RL_LOG_INFO, " %s", rlGetCompressedFormatName(compFormats[i]));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2668 RL_FREE(compFormats);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2669
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2670 #if defined(GRAPHICS_API_OPENGL_43)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2671 glGetIntegerv(GL_MAX_VERTEX_ATTRIB_BINDINGS, &capability);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2672 TRACELOG(RL_LOG_INFO, " GL_MAX_VERTEX_ATTRIB_BINDINGS: %i", capability);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2673 glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &capability);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2674 TRACELOG(RL_LOG_INFO, " GL_MAX_UNIFORM_LOCATIONS: %i", capability);
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2675 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2676
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2677 #else // !RLGL_SHOW_GL_DETAILS_INFO
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2678
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2679 // Show some basic info about GL supported features
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2680 if (RLGL.ExtSupported.vao) TRACELOG(RL_LOG_INFO, "GL: VAO extension detected, VAO functions loaded successfully");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2681 else TRACELOG(RL_LOG_WARNING, "GL: VAO extension not found, VAO not supported");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2682 if (RLGL.ExtSupported.texNPOT) TRACELOG(RL_LOG_INFO, "GL: NPOT textures extension detected, full NPOT textures supported");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2683 else TRACELOG(RL_LOG_WARNING, "GL: NPOT textures extension not found, limited NPOT support (no-mipmaps, no-repeat)");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2684 if (RLGL.ExtSupported.texCompDXT) TRACELOG(RL_LOG_INFO, "GL: DXT compressed textures supported");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2685 if (RLGL.ExtSupported.texCompETC1) TRACELOG(RL_LOG_INFO, "GL: ETC1 compressed textures supported");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2686 if (RLGL.ExtSupported.texCompETC2) TRACELOG(RL_LOG_INFO, "GL: ETC2/EAC compressed textures supported");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2687 if (RLGL.ExtSupported.texCompPVRT) TRACELOG(RL_LOG_INFO, "GL: PVRT compressed textures supported");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2688 if (RLGL.ExtSupported.texCompASTC) TRACELOG(RL_LOG_INFO, "GL: ASTC compressed textures supported");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2689 if (RLGL.ExtSupported.computeShader) TRACELOG(RL_LOG_INFO, "GL: Compute shaders supported");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2690 if (RLGL.ExtSupported.ssbo) TRACELOG(RL_LOG_INFO, "GL: Shader storage buffer objects supported");
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2691 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2692
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2693 #endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2694 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2695
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2696 // Get OpenGL procedure address
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2697 void *rlGetProcAddress(const char *procName)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2698 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2699 void *func = NULL;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2700 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2701 func = RLGL.loader(procName);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2702 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2703 return func;
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2704 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2705
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2706 // Get current OpenGL version
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2707 int rlGetVersion(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2708 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2709 int glVersion = 0;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2710
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2711 #if defined(GRAPHICS_API_OPENGL_SOFTWARE)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2712 glVersion = RL_OPENGL_SOFTWARE;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2713 #elif defined(GRAPHICS_API_OPENGL_11)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2714 glVersion = RL_OPENGL_11;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2715 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2716 #if defined(GRAPHICS_API_OPENGL_21)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2717 glVersion = RL_OPENGL_21;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2718 #elif defined(GRAPHICS_API_OPENGL_43)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2719 glVersion = RL_OPENGL_43;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2720 #elif defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2721 glVersion = RL_OPENGL_33;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2722 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2723 #if defined(GRAPHICS_API_OPENGL_ES3)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2724 glVersion = RL_OPENGL_ES_30;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2725 #elif defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2726 glVersion = RL_OPENGL_ES_20;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2727 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2728
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2729 return glVersion;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2730 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2731
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2732 // Set current framebuffer width
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2733 void rlSetFramebufferWidth(int width)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2734 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2735 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2736 RLGL.State.framebufferWidth = width;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2737 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2738 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2739
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2740 // Set current framebuffer height
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2741 void rlSetFramebufferHeight(int height)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2742 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2743 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2744 RLGL.State.framebufferHeight = height;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2745 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2746 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2747
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2748 // Get default framebuffer width
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2749 int rlGetFramebufferWidth(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2750 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2751 int width = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2752 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2753 width = RLGL.State.framebufferWidth;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2754 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2755 return width;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2756 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2757
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2758 // Get default framebuffer height
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2759 int rlGetFramebufferHeight(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2760 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2761 int height = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2762 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2763 height = RLGL.State.framebufferHeight;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2764 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2765 return height;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2766 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2767
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2768 // Get default internal texture (white texture)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2769 // NOTE: Default texture is a 1x1 pixel UNCOMPRESSED_R8G8B8A8
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2770 unsigned int rlGetTextureIdDefault(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2771 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2772 unsigned int id = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2773 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2774 id = RLGL.State.defaultTextureId;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2775 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2776 return id;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2777 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2778
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2779 // Get default shader id
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2780 unsigned int rlGetShaderIdDefault(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2781 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2782 unsigned int id = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2783 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2784 id = RLGL.State.defaultShaderId;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2785 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2786 return id;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2787 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2788
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2789 // Get default shader locs
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2790 int *rlGetShaderLocsDefault(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2791 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2792 int *locs = NULL;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2793 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2794 locs = RLGL.State.defaultShaderLocs;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2795 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2796 return locs;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2797 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2798
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2799 // Render batch management
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2800 //------------------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2801 // Load render batch
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2802 rlRenderBatch rlLoadRenderBatch(int numBuffers, int bufferElements)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2803 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2804 rlRenderBatch batch = { 0 };
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2805 if (!isGpuReady) { TRACELOG(RL_LOG_WARNING, "GL: GPU is not ready to load data, trying to load before InitWindow()?"); return batch; }
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2806
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2807 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2808 // Initialize CPU (RAM) vertex buffers (position, texcoord, color data and indexes)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2809 //--------------------------------------------------------------------------------------------
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2810 batch.vertexBuffer = (rlVertexBuffer *)RL_CALLOC(numBuffers, sizeof(rlVertexBuffer));
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2811
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2812 for (int i = 0; i < numBuffers; i++)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2813 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2814 batch.vertexBuffer[i].elementCount = bufferElements;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2815
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2816 batch.vertexBuffer[i].vertices = (float *)RL_CALLOC(bufferElements*3*4, sizeof(float)); // 3 float by vertex, 4 vertex by quad
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2817 batch.vertexBuffer[i].texcoords = (float *)RL_CALLOC(bufferElements*2*4, sizeof(float)); // 2 float by texcoord, 4 texcoord by quad
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2818 batch.vertexBuffer[i].normals = (float *)RL_CALLOC(bufferElements*3*4, sizeof(float)); // 3 float by vertex, 4 vertex by quad
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2819 batch.vertexBuffer[i].colors = (unsigned char *)RL_CALLOC(bufferElements*4*4, sizeof(unsigned char)); // 4 float by color, 4 colors by quad
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2820 #if defined(GRAPHICS_API_OPENGL_33)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2821 batch.vertexBuffer[i].indices = (unsigned int *)RL_CALLOC(bufferElements*6, sizeof(unsigned int)); // 6 int by quad (indices)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2822 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2823 #if defined(GRAPHICS_API_OPENGL_ES2)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2824 batch.vertexBuffer[i].indices = (unsigned short *)RL_CALLOC(bufferElements*6, sizeof(unsigned short)); // 6 int by quad (indices)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2825 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2826
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2827 for (int j = 0; j < (3*4*bufferElements); j++) batch.vertexBuffer[i].vertices[j] = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2828 for (int j = 0; j < (2*4*bufferElements); j++) batch.vertexBuffer[i].texcoords[j] = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2829 for (int j = 0; j < (3*4*bufferElements); j++) batch.vertexBuffer[i].normals[j] = 0.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2830 for (int j = 0; j < (4*4*bufferElements); j++) batch.vertexBuffer[i].colors[j] = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2831
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2832 int k = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2833
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2834 // Indices can be initialized right now
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2835 for (int j = 0; j < (6*bufferElements); j += 6)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2836 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2837 batch.vertexBuffer[i].indices[j] = 4*k;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2838 batch.vertexBuffer[i].indices[j + 1] = 4*k + 1;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2839 batch.vertexBuffer[i].indices[j + 2] = 4*k + 2;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2840 batch.vertexBuffer[i].indices[j + 3] = 4*k;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2841 batch.vertexBuffer[i].indices[j + 4] = 4*k + 2;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2842 batch.vertexBuffer[i].indices[j + 5] = 4*k + 3;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2843
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2844 k++;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2845 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2846
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2847 RLGL.State.vertexCounter = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2848 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2849
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2850 TRACELOG(RL_LOG_INFO, "RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2851 //--------------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2852
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2853 // Upload to GPU (VRAM) vertex data and initialize VAOs/VBOs
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2854 //--------------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2855 for (int i = 0; i < numBuffers; i++)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2856 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2857 if (RLGL.ExtSupported.vao)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2858 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2859 // Initialize Quads VAO
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2860 glGenVertexArrays(1, &batch.vertexBuffer[i].vaoId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2861 glBindVertexArray(batch.vertexBuffer[i].vaoId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2862 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2863
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2864 // Quads - Vertex buffers binding and attributes enable
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2865 // Vertex position buffer (shader-location = 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2866 glGenBuffers(1, &batch.vertexBuffer[i].vboId[0]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2867 glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBuffer[i].vboId[0]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2868 glBufferData(GL_ARRAY_BUFFER, bufferElements*3*4*sizeof(float), batch.vertexBuffer[i].vertices, GL_DYNAMIC_DRAW);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2869 glEnableVertexAttribArray(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_POSITION]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2870 glVertexAttribPointer(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_POSITION], 3, GL_FLOAT, 0, 0, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2871
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2872 // Vertex texcoord buffer (shader-location = 1)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2873 glGenBuffers(1, &batch.vertexBuffer[i].vboId[1]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2874 glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBuffer[i].vboId[1]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2875 glBufferData(GL_ARRAY_BUFFER, bufferElements*2*4*sizeof(float), batch.vertexBuffer[i].texcoords, GL_DYNAMIC_DRAW);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2876 glEnableVertexAttribArray(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_TEXCOORD01]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2877 glVertexAttribPointer(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_TEXCOORD01], 2, GL_FLOAT, 0, 0, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2878
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2879 // Vertex normal buffer (shader-location = 2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2880 glGenBuffers(1, &batch.vertexBuffer[i].vboId[2]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2881 glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBuffer[i].vboId[2]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2882 glBufferData(GL_ARRAY_BUFFER, bufferElements*3*4*sizeof(float), batch.vertexBuffer[i].normals, GL_DYNAMIC_DRAW);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2883 glEnableVertexAttribArray(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_NORMAL]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2884 glVertexAttribPointer(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_NORMAL], 3, GL_FLOAT, 0, 0, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2885
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2886 // Vertex color buffer (shader-location = 3)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2887 glGenBuffers(1, &batch.vertexBuffer[i].vboId[3]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2888 glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBuffer[i].vboId[3]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2889 glBufferData(GL_ARRAY_BUFFER, bufferElements*4*4*sizeof(unsigned char), batch.vertexBuffer[i].colors, GL_DYNAMIC_DRAW);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2890 glEnableVertexAttribArray(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_COLOR]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2891 glVertexAttribPointer(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_COLOR], 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2892
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2893 // Fill index buffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2894 glGenBuffers(1, &batch.vertexBuffer[i].vboId[4]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2895 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, batch.vertexBuffer[i].vboId[4]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2896 #if defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2897 glBufferData(GL_ELEMENT_ARRAY_BUFFER, bufferElements*6*sizeof(int), batch.vertexBuffer[i].indices, GL_STATIC_DRAW);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2898 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2899 #if defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2900 glBufferData(GL_ELEMENT_ARRAY_BUFFER, bufferElements*6*sizeof(short), batch.vertexBuffer[i].indices, GL_STATIC_DRAW);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2901 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2902 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2903
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2904 TRACELOG(RL_LOG_INFO, "RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2905
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2906 // Unbind the current VAO
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2907 if (RLGL.ExtSupported.vao) glBindVertexArray(0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2908 //--------------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2909
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2910 // Init draw calls tracking system
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2911 //--------------------------------------------------------------------------------------------
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2912 batch.draws = (rlDrawCall *)RL_CALLOC(RL_DEFAULT_BATCH_DRAWCALLS, sizeof(rlDrawCall));
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2913
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2914 for (int i = 0; i < RL_DEFAULT_BATCH_DRAWCALLS; i++)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2915 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2916 batch.draws[i].mode = RL_QUADS;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2917 batch.draws[i].vertexCount = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2918 batch.draws[i].vertexAlignment = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2919 //batch.draws[i].vaoId = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2920 //batch.draws[i].shaderId = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2921 batch.draws[i].textureId = RLGL.State.defaultTextureId;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2922 //batch.draws[i].RLGL.State.projection = rlMatrixIdentity();
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2923 //batch.draws[i].RLGL.State.modelview = rlMatrixIdentity();
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2924 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2925
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2926 batch.bufferCount = numBuffers; // Record buffer count
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2927 batch.drawCounter = 1; // Reset draws counter
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2928 batch.currentDepth = -1.0f; // Reset depth value
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2929 //--------------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2930 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2931
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2932 return batch;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2933 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2934
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2935 // Unload default internal buffers vertex data from CPU and GPU
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2936 void rlUnloadRenderBatch(rlRenderBatch batch)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2937 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2938 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2939 // Unbind everything
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2940 glBindBuffer(GL_ARRAY_BUFFER, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2941 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2942
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2943 // Unload all vertex buffers data
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2944 for (int i = 0; i < batch.bufferCount; i++)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2945 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2946 // Unbind VAO attribs data
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2947 if (RLGL.ExtSupported.vao)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2948 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2949 glBindVertexArray(batch.vertexBuffer[i].vaoId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2950 glDisableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2951 glDisableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2952 glDisableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2953 glDisableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2954 glBindVertexArray(0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2955 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2956
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2957 // Delete VBOs from GPU (VRAM)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2958 glDeleteBuffers(1, &batch.vertexBuffer[i].vboId[0]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2959 glDeleteBuffers(1, &batch.vertexBuffer[i].vboId[1]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2960 glDeleteBuffers(1, &batch.vertexBuffer[i].vboId[2]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2961 glDeleteBuffers(1, &batch.vertexBuffer[i].vboId[3]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2962 glDeleteBuffers(1, &batch.vertexBuffer[i].vboId[4]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2963
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2964 // Delete VAOs from GPU (VRAM)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2965 if (RLGL.ExtSupported.vao) glDeleteVertexArrays(1, &batch.vertexBuffer[i].vaoId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2966
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2967 // Free vertex arrays memory from CPU (RAM)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2968 RL_FREE(batch.vertexBuffer[i].vertices);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2969 RL_FREE(batch.vertexBuffer[i].texcoords);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2970 RL_FREE(batch.vertexBuffer[i].normals);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2971 RL_FREE(batch.vertexBuffer[i].colors);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2972 RL_FREE(batch.vertexBuffer[i].indices);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2973 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2974
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2975 // Unload arrays
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2976 RL_FREE(batch.vertexBuffer);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2977 RL_FREE(batch.draws);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2978 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2979 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2980
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2981 // Draw render batch
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2982 // NOTE: Batch is reseted and current buffer is updated (for multi-buffer config)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2983 void rlDrawRenderBatch(rlRenderBatch *batch)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2984 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2985 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2986 // Update batch vertex buffers
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2987 //------------------------------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2988 // NOTE: If there is not vertex data, buffers doesn't need to be updated (vertexCount > 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2989 if (RLGL.State.vertexCounter > 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2990 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2991 // Activate elements VAO
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2992 if (RLGL.ExtSupported.vao) glBindVertexArray(batch->vertexBuffer[batch->currentBuffer].vaoId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2993
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2994 // TODO: If no data changed on the CPU arrays there is no need to re-upload data to GPU,
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2995 // a flag can be used to detect changes but it would imply keeping a copy buffer and memcmp() both, does it worth it?
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
2996
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2997 // Vertex positions buffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2998 glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[0]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2999 glBufferSubData(GL_ARRAY_BUFFER, 0, RLGL.State.vertexCounter*3*sizeof(float), batch->vertexBuffer[batch->currentBuffer].vertices);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3000 //glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*4*batch->vertexBuffer[batch->currentBuffer].elementCount, batch->vertexBuffer[batch->currentBuffer].vertices, GL_DYNAMIC_DRAW); // Update all buffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3001
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3002 // Texture coordinates buffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3003 glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[1]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3004 glBufferSubData(GL_ARRAY_BUFFER, 0, RLGL.State.vertexCounter*2*sizeof(float), batch->vertexBuffer[batch->currentBuffer].texcoords);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3005 //glBufferData(GL_ARRAY_BUFFER, sizeof(float)*2*4*batch->vertexBuffer[batch->currentBuffer].elementCount, batch->vertexBuffer[batch->currentBuffer].texcoords, GL_DYNAMIC_DRAW); // Update all buffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3006
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3007 // Normals buffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3008 glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[2]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3009 glBufferSubData(GL_ARRAY_BUFFER, 0, RLGL.State.vertexCounter*3*sizeof(float), batch->vertexBuffer[batch->currentBuffer].normals);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3010 //glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*4*batch->vertexBuffer[batch->currentBuffer].elementCount, batch->vertexBuffer[batch->currentBuffer].normals, GL_DYNAMIC_DRAW); // Update all buffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3011
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3012 // Colors buffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3013 glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[3]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3014 glBufferSubData(GL_ARRAY_BUFFER, 0, RLGL.State.vertexCounter*4*sizeof(unsigned char), batch->vertexBuffer[batch->currentBuffer].colors);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3015 //glBufferData(GL_ARRAY_BUFFER, sizeof(float)*4*4*batch->vertexBuffer[batch->currentBuffer].elementCount, batch->vertexBuffer[batch->currentBuffer].colors, GL_DYNAMIC_DRAW); // Update all buffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3016
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3017 // NOTE: glMapBuffer() causes sync issue
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3018 // If GPU is working with this buffer, glMapBuffer() will wait(stall) until GPU to finish its job
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3019 // To avoid waiting (idle), glBufferData() can bee called first with NULL pointer before glMapBuffer()
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3020 // Doing that, the previous data in PBO will be discarded and glMapBuffer() returns a new
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3021 // allocated pointer immediately even if GPU is still working with the previous data
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3022
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3023 // Another option: map the buffer object into client's memory
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3024 //batch->vertexBuffer[batch->currentBuffer].vertices = (float *)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3025 //if (batch->vertexBuffer[batch->currentBuffer].vertices)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3026 //{
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3027 // Update vertex data
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3028 //}
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3029 //glUnmapBuffer(GL_ARRAY_BUFFER);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3030
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3031 // Unbind the current VAO
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3032 if (RLGL.ExtSupported.vao) glBindVertexArray(0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3033 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3034 //------------------------------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3035
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3036 // Draw batch vertex buffers (considering VR stereo if required)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3037 //------------------------------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3038 Matrix matProjection = RLGL.State.projection;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3039 Matrix matModelView = RLGL.State.modelview;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3040
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3041 int eyeCount = 1;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3042 if (RLGL.State.stereoRender) eyeCount = 2;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3043
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3044 for (int eye = 0; eye < eyeCount; eye++)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3045 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3046 if (eyeCount == 2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3047 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3048 // Setup current eye viewport (half screen width)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3049 rlViewport(eye*RLGL.State.framebufferWidth/2, 0, RLGL.State.framebufferWidth/2, RLGL.State.framebufferHeight);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3050
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3051 // Set current eye view offset to modelview matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3052 rlSetMatrixModelview(rlMatrixMultiply(matModelView, RLGL.State.viewOffsetStereo[eye]));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3053 // Set current eye projection matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3054 rlSetMatrixProjection(RLGL.State.projectionStereo[eye]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3055 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3056
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3057 // Draw buffers
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3058 if (RLGL.State.vertexCounter > 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3059 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3060 // Set current shader and upload current MVP matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3061 glUseProgram(RLGL.State.currentShaderId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3062
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3063 // Create modelview-projection matrix and upload to shader
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3064 Matrix matMVP = rlMatrixMultiply(RLGL.State.modelview, RLGL.State.projection);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3065 glUniformMatrix4fv(RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_MVP], 1, false, rlMatrixToFloat(matMVP));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3066
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3067 if (RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_PROJECTION] != -1)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3068 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3069 glUniformMatrix4fv(RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_PROJECTION], 1, false, rlMatrixToFloat(RLGL.State.projection));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3070 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3071
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3072 // WARNING: For the following setup of the view, model, and normal matrices, it is expected that
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3073 // transformations and rendering occur between rlPushMatrix() and rlPopMatrix()
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3074
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3075 if (RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_VIEW] != -1)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3076 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3077 glUniformMatrix4fv(RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_VIEW], 1, false, rlMatrixToFloat(RLGL.State.modelview));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3078 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3079
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3080 if (RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_MODEL] != -1)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3081 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3082 glUniformMatrix4fv(RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_MODEL], 1, false, rlMatrixToFloat(RLGL.State.transform));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3083 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3084
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3085 if (RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_NORMAL] != -1)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3086 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3087 glUniformMatrix4fv(RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_NORMAL], 1, false, rlMatrixToFloat(rlMatrixTranspose(rlMatrixInvert(RLGL.State.transform))));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3088 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3089
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3090 if (RLGL.ExtSupported.vao) glBindVertexArray(batch->vertexBuffer[batch->currentBuffer].vaoId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3091 else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3092 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3093 // Bind vertex attrib: position (shader-location = 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3094 glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[0]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3095 glVertexAttribPointer(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_POSITION], 3, GL_FLOAT, 0, 0, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3096 glEnableVertexAttribArray(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_POSITION]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3097
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3098 // Bind vertex attrib: texcoord (shader-location = 1)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3099 glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[1]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3100 glVertexAttribPointer(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_TEXCOORD01], 2, GL_FLOAT, 0, 0, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3101 glEnableVertexAttribArray(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_TEXCOORD01]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3102
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3103 // Bind vertex attrib: normal (shader-location = 2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3104 glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[2]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3105 glVertexAttribPointer(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_NORMAL], 3, GL_FLOAT, 0, 0, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3106 glEnableVertexAttribArray(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_NORMAL]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3107
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3108 // Bind vertex attrib: color (shader-location = 3)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3109 glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[3]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3110 glVertexAttribPointer(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_COLOR], 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3111 glEnableVertexAttribArray(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_COLOR]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3112
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3113 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[4]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3114 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3115
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3116 // Setup some default shader values
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3117 glUniform4f(RLGL.State.currentShaderLocs[RL_SHADER_LOC_COLOR_DIFFUSE], 1.0f, 1.0f, 1.0f, 1.0f);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3118 glUniform1i(RLGL.State.currentShaderLocs[RL_SHADER_LOC_MAP_DIFFUSE], 0); // Active default sampler2D: texture0
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3119
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3120 // Activate additional sampler textures
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3121 // Those additional textures will be common for all draw calls of the batch
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3122 for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3123 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3124 if (RLGL.State.activeTextureId[i] > 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3125 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3126 glActiveTexture(GL_TEXTURE0 + 1 + i);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3127 glBindTexture(GL_TEXTURE_2D, RLGL.State.activeTextureId[i]);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3128 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3129 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3130
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3131 // Activate default sampler2D texture0 (one texture is always active for default batch shader)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3132 // NOTE: Batch system accumulates calls by texture0 changes, additional textures are enabled for all the draw calls
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3133 glActiveTexture(GL_TEXTURE0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3134
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3135 for (int i = 0, vertexOffset = 0; i < batch->drawCounter; i++)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3136 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3137 // Bind current draw call texture, activated as GL_TEXTURE0 and bound to sampler2D texture0 by default
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3138 glBindTexture(GL_TEXTURE_2D, batch->draws[i].textureId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3139
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3140 if ((batch->draws[i].mode == RL_LINES) || (batch->draws[i].mode == RL_TRIANGLES)) glDrawArrays(batch->draws[i].mode, vertexOffset, batch->draws[i].vertexCount);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3141 else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3142 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3143 #if defined(GRAPHICS_API_OPENGL_33)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3144 // The number of indices to be processed needs to be defined: elementCount*6
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3145 // NOTE: The final parameter tells the GPU the offset in bytes from the
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3146 // start of the index buffer to the location of the first index to process
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3147 glDrawElements(GL_TRIANGLES, batch->draws[i].vertexCount/4*6, GL_UNSIGNED_INT, (GLvoid *)(vertexOffset/4*6*sizeof(GLuint)));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3148 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3149 #if defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3150 glDrawElements(GL_TRIANGLES, batch->draws[i].vertexCount/4*6, GL_UNSIGNED_SHORT, (GLvoid *)(vertexOffset/4*6*sizeof(GLushort)));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3151 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3152 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3153
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3154 vertexOffset += (batch->draws[i].vertexCount + batch->draws[i].vertexAlignment);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3155 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3156
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3157 if (!RLGL.ExtSupported.vao)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3158 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3159 glBindBuffer(GL_ARRAY_BUFFER, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3160 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3161 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3162
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3163 glBindTexture(GL_TEXTURE_2D, 0); // Unbind textures
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3164 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3165
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3166 if (RLGL.ExtSupported.vao) glBindVertexArray(0); // Unbind VAO
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3167
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3168 glUseProgram(0); // Unbind shader program
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3169 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3170
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3171 // Restore viewport to default measures
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3172 if (eyeCount == 2) rlViewport(0, 0, RLGL.State.framebufferWidth, RLGL.State.framebufferHeight);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3173 //------------------------------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3174
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3175 // Reset batch buffers
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3176 //------------------------------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3177 // Reset vertex counter for next frame
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3178 RLGL.State.vertexCounter = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3179
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3180 // Reset depth for next draw
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3181 batch->currentDepth = -1.0f;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3182
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3183 // Restore projection/modelview matrices
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3184 RLGL.State.projection = matProjection;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3185 RLGL.State.modelview = matModelView;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3186
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3187 // Reset RLGL.currentBatch->draws array
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3188 for (int i = 0; i < RL_DEFAULT_BATCH_DRAWCALLS; i++)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3189 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3190 batch->draws[i].mode = RL_QUADS;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3191 batch->draws[i].vertexCount = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3192 batch->draws[i].textureId = RLGL.State.defaultTextureId;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3193 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3194
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3195 // Reset active texture units for next batch
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3196 for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++) RLGL.State.activeTextureId[i] = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3197
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3198 // Reset draws counter to one draw for the batch
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3199 batch->drawCounter = 1;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3200 //------------------------------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3201
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3202 // Change to next buffer in the list (in case of multi-buffering)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3203 batch->currentBuffer++;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3204 if (batch->currentBuffer >= batch->bufferCount) batch->currentBuffer = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3205 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3206 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3207
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3208 // Set the active render batch for rlgl
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3209 void rlSetRenderBatchActive(rlRenderBatch *batch)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3210 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3211 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3212 rlDrawRenderBatch(RLGL.currentBatch);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3213
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3214 if (batch != NULL) RLGL.currentBatch = batch;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3215 else RLGL.currentBatch = &RLGL.defaultBatch;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3216 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3217 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3218
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3219 // Update and draw internal render batch
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3220 void rlDrawRenderBatchActive(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3221 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3222 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3223 rlDrawRenderBatch(RLGL.currentBatch); // NOTE: Stereo rendering is checked inside
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3224 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3225 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3226
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3227 // Check internal buffer overflow for a given number of vertex
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3228 // and force a rlRenderBatch draw call if required
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3229 bool rlCheckRenderBatchLimit(int vCount)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3230 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3231 bool overflow = false;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3232
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3233 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3234 if ((RLGL.State.vertexCounter + vCount) >=
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3235 (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3236 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3237 overflow = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3238
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3239 // Store current primitive drawing mode and texture id
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3240 int currentMode = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3241 int currentTexture = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3242
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3243 rlDrawRenderBatch(RLGL.currentBatch); // NOTE: Stereo rendering is checked inside
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3244
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3245 // Restore state of last batch so new vertices can be added
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3246 RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = currentMode;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3247 RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = currentTexture;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3248 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3249 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3250
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3251 return overflow;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3252 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3253
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3254 // Textures data management
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3255 //-----------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3256 // Convert image data to OpenGL texture (returns OpenGL valid Id)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3257 unsigned int rlLoadTexture(const void *data, int width, int height, int format, int mipmapCount)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3258 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3259 unsigned int id = 0;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3260 if (!isGpuReady) { TRACELOG(RL_LOG_WARNING, "GL: GPU is not ready to load data, trying to load before InitWindow()?"); return id; }
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3261
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3262 glBindTexture(GL_TEXTURE_2D, 0); // Free any old binding
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3263
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3264 // Check texture format support by OpenGL 1.1 (compressed textures not supported)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3265 #if defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3266 if (format >= RL_PIXELFORMAT_COMPRESSED_DXT1_RGB)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3267 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3268 // TODO: Support texture data decompression
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3269 TRACELOG(RL_LOG_WARNING, "GL: OpenGL 1.1 does not support GPU compressed texture formats");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3270 return id;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3271 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3272 #else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3273 if ((!RLGL.ExtSupported.texCompDXT) && ((format == RL_PIXELFORMAT_COMPRESSED_DXT1_RGB) || (format == RL_PIXELFORMAT_COMPRESSED_DXT1_RGBA) ||
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3274 (format == RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA) || (format == RL_PIXELFORMAT_COMPRESSED_DXT5_RGBA)))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3275 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3276 TRACELOG(RL_LOG_WARNING, "GL: DXT compressed texture format not supported");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3277 return id;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3278 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3279 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3280 if ((!RLGL.ExtSupported.texCompETC1) && (format == RL_PIXELFORMAT_COMPRESSED_ETC1_RGB))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3281 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3282 TRACELOG(RL_LOG_WARNING, "GL: ETC1 compressed texture format not supported");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3283 return id;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3284 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3285
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3286 if ((!RLGL.ExtSupported.texCompETC2) && ((format == RL_PIXELFORMAT_COMPRESSED_ETC2_RGB) || (format == RL_PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA)))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3287 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3288 TRACELOG(RL_LOG_WARNING, "GL: ETC2 compressed texture format not supported");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3289 return id;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3290 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3291
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3292 if ((!RLGL.ExtSupported.texCompPVRT) && ((format == RL_PIXELFORMAT_COMPRESSED_PVRT_RGB) || (format == RL_PIXELFORMAT_COMPRESSED_PVRT_RGBA)))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3293 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3294 TRACELOG(RL_LOG_WARNING, "GL: PVRT compressed texture format not supported");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3295 return id;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3296 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3297
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3298 if ((!RLGL.ExtSupported.texCompASTC) && ((format == RL_PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA) || (format == RL_PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA)))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3299 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3300 TRACELOG(RL_LOG_WARNING, "GL: ASTC compressed texture format not supported");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3301 return id;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3302 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3303 #endif
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3304 #endif // GRAPHICS_API_OPENGL_11
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3305
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3306 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3307
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3308 glGenTextures(1, &id); // Generate texture id
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3309
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3310 glBindTexture(GL_TEXTURE_2D, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3311
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3312 int mipWidth = width;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3313 int mipHeight = height;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3314 int mipOffset = 0; // Mipmap data offset, only used for tracelog
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3315 (void)mipOffset; // Used to avoid gcc warnings about unused variable
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3316
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3317 // NOTE: Added pointer math separately from function to avoid UBSAN complaining
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3318 unsigned char *dataPtr = NULL;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3319 if (data != NULL) dataPtr = (unsigned char *)data;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3320
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3321 // Load the different mipmap levels
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3322 for (int i = 0; i < mipmapCount; i++)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3323 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3324 unsigned int mipSize = rlGetPixelDataSize(mipWidth, mipHeight, format);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3325
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3326 unsigned int glInternalFormat, glFormat, glType;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3327 rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3328
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3329 TRACELOG(RL_LOG_DEBUG, "TEXTURE: Load mipmap level %i (%i x %i), size: %i, offset: %i", i, mipWidth, mipHeight, mipSize, mipOffset);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3330
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3331 if (glInternalFormat != 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3332 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3333 if (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB) glTexImage2D(GL_TEXTURE_2D, i, glInternalFormat, mipWidth, mipHeight, 0, glFormat, glType, dataPtr);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3334 #if !defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3335 else glCompressedTexImage2D(GL_TEXTURE_2D, i, glInternalFormat, mipWidth, mipHeight, 0, mipSize, dataPtr);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3336 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3337
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3338 #if defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3339 if (format == RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3340 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3341 GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_ONE };
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3342 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3343 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3344 else if (format == RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3345 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3346 #if defined(GRAPHICS_API_OPENGL_21)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3347 GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_ALPHA };
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3348 #elif defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3349 GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_GREEN };
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3350 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3351 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3352 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3353 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3354 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3355
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3356 mipWidth /= 2;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3357 mipHeight /= 2;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3358 mipOffset += mipSize; // Increment offset position to next mipmap
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3359 if (data != NULL) dataPtr += mipSize; // Increment data pointer to next mipmap
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3360
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3361 // Security check for NPOT textures
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3362 if (mipWidth < 1) mipWidth = 1;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3363 if (mipHeight < 1) mipHeight = 1;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3364 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3365
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3366 // Texture parameters configuration
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3367 // NOTE: glTexParameteri does NOT affect texture uploading
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3368 #if defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3369 // 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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3370 if (RLGL.ExtSupported.texNPOT)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3371 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3372 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // Set texture to repeat on x-axis
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3373 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // Set texture to repeat on y-axis
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3374 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3375 else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3376 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3377 // NOTE: If using negative texture coordinates (LoadOBJ()), it does not work!
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3378 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // Set texture to clamp on x-axis
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3379 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Set texture to clamp on y-axis
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3380 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3381 #else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3382 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // Set texture to repeat on x-axis
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3383 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // Set texture to repeat on y-axis
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3384 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3385
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3386 // Magnification and minification filters
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3387 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // Alternative: GL_LINEAR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3388 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // Alternative: GL_LINEAR
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3389
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3390 #if defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3391 if (mipmapCount > 1)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3392 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3393 // Activate trilinear filtering if mipmaps are available
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3394 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3395 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3396
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3397 // Define the maximum number of mipmap levels to be used, 0 is base texture size
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3398 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3399 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipmapCount - 1);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3400
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3401 // Check if the loaded texture with mipmaps is complete,
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3402 // uncomplete textures will draw in black if mipmap filtering is required
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3403 //GLint complete = 0;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3404 //glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_FORMAT, &complete);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3405 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3406 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3407
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3408 // At this point texture is loaded in GPU and texture parameters configured
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3409
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3410 // NOTE: If mipmaps were not in data, they are not generated automatically
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3411
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3412 // Unbind current texture
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3413 glBindTexture(GL_TEXTURE_2D, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3414
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3415 if (id > 0) TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Texture loaded successfully (%ix%i | %s | %i mipmaps)", id, width, height, rlGetPixelFormatName(format), mipmapCount);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3416 else TRACELOG(RL_LOG_WARNING, "TEXTURE: Failed to load texture");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3417
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3418 return id;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3419 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3420
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3421 // Load depth texture/renderbuffer (to be attached to fbo)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3422 // WARNING: OpenGL ES 2.0 requires GL_OES_depth_texture and WebGL requires WEBGL_depth_texture extensions
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3423 unsigned int rlLoadTextureDepth(int width, int height, bool useRenderBuffer)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3424 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3425 unsigned int id = 0;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3426 if (!isGpuReady) { TRACELOG(RL_LOG_WARNING, "GL: GPU is not ready to load data, trying to load before InitWindow()?"); return id; }
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3427
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3428 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3429 // In case depth textures were not supported, force renderbuffer usage
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3430 if (!RLGL.ExtSupported.texDepth) useRenderBuffer = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3431
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3432 // NOTE: Letting the implementation to choose the best bit-depth
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3433 // Possible formats: GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT32 and GL_DEPTH_COMPONENT32F
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3434 unsigned int glInternalFormat = GL_DEPTH_COMPONENT;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3435
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3436 #if defined(GRAPHICS_API_OPENGL_ES2)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3437 // WARNING: WebGL platform requires unsized internal format definition (GL_DEPTH_COMPONENT)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3438 // while other platforms using OpenGL ES 2.0 require/support sized internal formats depending on the GPU capabilities
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3439 if (!RLGL.ExtSupported.texDepthWebGL || useRenderBuffer)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3440 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3441 if (RLGL.ExtSupported.maxDepthBits == 32) glInternalFormat = GL_DEPTH_COMPONENT32_OES;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3442 else if (RLGL.ExtSupported.maxDepthBits == 24) glInternalFormat = GL_DEPTH_COMPONENT24_OES;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3443 else glInternalFormat = GL_DEPTH_COMPONENT16;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3444 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3445 #endif
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3446 #if defined(GRAPHICS_API_OPENGL_ES3)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3447 // NOTE: This sized internal format should also work for WebGL 2.0
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3448 // WARNING: Specification only allows GL_DEPTH_COMPONENT32F for GL_FLOAT type
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3449 // REF: https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3450 if (RLGL.ExtSupported.maxDepthBits == 24) glInternalFormat = GL_DEPTH_COMPONENT24;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3451 else glInternalFormat = GL_DEPTH_COMPONENT16;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3452 #endif
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3453
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3454 if (!useRenderBuffer && RLGL.ExtSupported.texDepth)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3455 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3456 glGenTextures(1, &id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3457 glBindTexture(GL_TEXTURE_2D, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3458 glTexImage2D(GL_TEXTURE_2D, 0, glInternalFormat, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3459
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3460 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3461 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3462 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3463 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3464
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3465 glBindTexture(GL_TEXTURE_2D, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3466
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3467 TRACELOG(RL_LOG_INFO, "TEXTURE: Depth texture loaded successfully");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3468 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3469 else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3470 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3471 // Create the renderbuffer that will serve as the depth attachment for the framebuffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3472 // NOTE: A renderbuffer is simpler than a texture and could offer better performance on embedded devices
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3473 glGenRenderbuffers(1, &id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3474 glBindRenderbuffer(GL_RENDERBUFFER, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3475 glRenderbufferStorage(GL_RENDERBUFFER, glInternalFormat, width, height);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3476
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3477 glBindRenderbuffer(GL_RENDERBUFFER, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3478
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3479 TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Depth renderbuffer loaded successfully (%i bits)", id, (RLGL.ExtSupported.maxDepthBits >= 24)? RLGL.ExtSupported.maxDepthBits : 16);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3480 }
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3481 #elif defined(GRAPHICS_API_OPENGL_SOFTWARE)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3482 // NOTE: Renderbuffers are the same type of object as textures in rlsw
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3483 // WARNING: Ensure that the depth format is the one specified at rlsw compilation
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3484 glGenRenderbuffers(1, &id);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3485 glBindRenderbuffer(GL_RENDERBUFFER, id);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3486 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32, width, height);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3487 glBindRenderbuffer(GL_RENDERBUFFER, 0);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3488 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3489
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3490 return id;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3491 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3492
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3493 // Load texture cubemap
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3494 // NOTE: Cubemap data is expected to be 6 images in a single data array (one after the other),
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3495 // expected the following convention: +X, -X, +Y, -Y, +Z, -Z
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3496 unsigned int rlLoadTextureCubemap(const void *data, int size, int format, int mipmapCount)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3497 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3498 unsigned int id = 0;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3499 if (!isGpuReady) { TRACELOG(RL_LOG_WARNING, "GL: GPU is not ready to load data, trying to load before InitWindow()?"); return id; }
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3500
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3501 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3502 int mipSize = size;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3503
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3504 // NOTE: Added pointer math separately from function to avoid UBSAN complaining
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3505 unsigned char *dataPtr = NULL;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3506 if (data != NULL) dataPtr = (unsigned char *)data;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3507
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3508 unsigned int dataSize = rlGetPixelDataSize(size, size, format);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3509
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3510 glGenTextures(1, &id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3511 glBindTexture(GL_TEXTURE_CUBE_MAP, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3512
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3513 unsigned int glInternalFormat, glFormat, glType;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3514 rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3515
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3516 if (glInternalFormat != 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3517 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3518 // Load cubemap faces/mipmaps
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3519 for (int i = 0; i < 6*mipmapCount; i++)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3520 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3521 int mipmapLevel = i/6;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3522 int face = i%6;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3523
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3524 if (data == NULL)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3525 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3526 if (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3527 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3528 if ((format == RL_PIXELFORMAT_UNCOMPRESSED_R32) ||
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3529 (format == RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32) ||
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3530 (format == RL_PIXELFORMAT_UNCOMPRESSED_R16) ||
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3531 (format == RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16)) TRACELOG(RL_LOG_WARNING, "TEXTURES: Cubemap requested format not supported");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3532 else glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, mipmapLevel, glInternalFormat, mipSize, mipSize, 0, glFormat, glType, NULL);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3533 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3534 else TRACELOG(RL_LOG_WARNING, "TEXTURES: Empty cubemap creation does not support compressed format");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3535 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3536 else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3537 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3538 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);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3539 else glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, mipmapLevel, glInternalFormat, mipSize, mipSize, 0, dataSize, (unsigned char *)dataPtr + face*dataSize);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3540 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3541
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3542 #if defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3543 if (format == RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3544 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3545 GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_ONE };
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3546 glTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3547 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3548 else if (format == RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3549 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3550 #if defined(GRAPHICS_API_OPENGL_21)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3551 GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_ALPHA };
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3552 #elif defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3553 GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_GREEN };
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3554 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3555 glTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3556 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3557 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3558 if (face == 5)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3559 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3560 mipSize /= 2;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3561 if (data != NULL) dataPtr += dataSize*6; // Increment data pointer to next mipmap
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3562
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3563 // Security check for NPOT textures
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3564 if (mipSize < 1) mipSize = 1;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3565
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3566 dataSize = rlGetPixelDataSize(mipSize, mipSize, format);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3567 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3568 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3569 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3570
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3571 // Set cubemap texture sampling parameters
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3572 if (mipmapCount > 1) glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3573 else glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3574
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3575 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3576 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3577 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3578 #if defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3579 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); // Flag not supported on OpenGL ES 2.0
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3580 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3581
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3582 glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3583 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3584
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3585 if (id > 0) TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Cubemap texture loaded successfully (%ix%i)", id, size, size);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3586 else TRACELOG(RL_LOG_WARNING, "TEXTURE: Failed to load cubemap texture");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3587
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3588 return id;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3589 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3590
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3591 // Update already loaded texture in GPU with new data
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3592 // WARNING: Not possible to know safely if internal texture format is the expected one...
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3593 void rlUpdateTexture(unsigned int id, int offsetX, int offsetY, int width, int height, int format, const void *data)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3594 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3595 glBindTexture(GL_TEXTURE_2D, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3596
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3597 unsigned int glInternalFormat, glFormat, glType;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3598 rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3599
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3600 if ((glInternalFormat != 0) && (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3601 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3602 glTexSubImage2D(GL_TEXTURE_2D, 0, offsetX, offsetY, width, height, glFormat, glType, data);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3603 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3604 else TRACELOG(RL_LOG_WARNING, "TEXTURE: [ID %i] Failed to update for current texture format (%i)", id, format);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3605 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3606
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3607 // Get OpenGL internal formats and data type from raylib PixelFormat
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3608 void rlGetGlTextureFormats(int format, unsigned int *glInternalFormat, unsigned int *glFormat, unsigned int *glType)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3609 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3610 *glInternalFormat = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3611 *glFormat = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3612 *glType = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3613
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3614 switch (format)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3615 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3616 #if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_21) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3617 // NOTE: on OpenGL ES 2.0 (WebGL), internalFormat must match format and options allowed are: GL_LUMINANCE, GL_RGB, GL_RGBA
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3618 case RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE: *glInternalFormat = GL_LUMINANCE; *glFormat = GL_LUMINANCE; *glType = GL_UNSIGNED_BYTE; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3619 case RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA: *glInternalFormat = GL_LUMINANCE_ALPHA; *glFormat = GL_LUMINANCE_ALPHA; *glType = GL_UNSIGNED_BYTE; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3620 case RL_PIXELFORMAT_UNCOMPRESSED_R5G6B5: *glInternalFormat = GL_RGB; *glFormat = GL_RGB; *glType = GL_UNSIGNED_SHORT_5_6_5; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3621 case RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8: *glInternalFormat = GL_RGB; *glFormat = GL_RGB; *glType = GL_UNSIGNED_BYTE; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3622 case RL_PIXELFORMAT_UNCOMPRESSED_R5G5B5A1: *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_UNSIGNED_SHORT_5_5_5_1; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3623 case RL_PIXELFORMAT_UNCOMPRESSED_R4G4B4A4: *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_UNSIGNED_SHORT_4_4_4_4; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3624 case RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_UNSIGNED_BYTE; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3625 #if !defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3626 #if defined(GRAPHICS_API_OPENGL_ES3)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3627 case RL_PIXELFORMAT_UNCOMPRESSED_R32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_R32F_EXT; *glFormat = GL_RED_EXT; *glType = GL_FLOAT; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3628 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGB32F_EXT; *glFormat = GL_RGB; *glType = GL_FLOAT; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3629 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGBA32F_EXT; *glFormat = GL_RGBA; *glType = GL_FLOAT; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3630 case RL_PIXELFORMAT_UNCOMPRESSED_R16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_R16F_EXT; *glFormat = GL_RED_EXT; *glType = GL_HALF_FLOAT; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3631 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGB16F_EXT; *glFormat = GL_RGB; *glType = GL_HALF_FLOAT; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3632 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGBA16F_EXT; *glFormat = GL_RGBA; *glType = GL_HALF_FLOAT; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3633 #else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3634 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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3635 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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3636 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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3637 #if defined(GRAPHICS_API_OPENGL_21)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3638 case RL_PIXELFORMAT_UNCOMPRESSED_R16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_LUMINANCE; *glFormat = GL_LUMINANCE; *glType = GL_HALF_FLOAT_ARB; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3639 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGB; *glFormat = GL_RGB; *glType = GL_HALF_FLOAT_ARB; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3640 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_HALF_FLOAT_ARB; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3641 #else // defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3642 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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3643 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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3644 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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3645 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3646 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3647 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3648 #elif defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3649 case RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE: *glInternalFormat = GL_R8; *glFormat = GL_RED; *glType = GL_UNSIGNED_BYTE; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3650 case RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA: *glInternalFormat = GL_RG8; *glFormat = GL_RG; *glType = GL_UNSIGNED_BYTE; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3651 case RL_PIXELFORMAT_UNCOMPRESSED_R5G6B5: *glInternalFormat = GL_RGB565; *glFormat = GL_RGB; *glType = GL_UNSIGNED_SHORT_5_6_5; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3652 case RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8: *glInternalFormat = GL_RGB8; *glFormat = GL_RGB; *glType = GL_UNSIGNED_BYTE; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3653 case RL_PIXELFORMAT_UNCOMPRESSED_R5G5B5A1: *glInternalFormat = GL_RGB5_A1; *glFormat = GL_RGBA; *glType = GL_UNSIGNED_SHORT_5_5_5_1; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3654 case RL_PIXELFORMAT_UNCOMPRESSED_R4G4B4A4: *glInternalFormat = GL_RGBA4; *glFormat = GL_RGBA; *glType = GL_UNSIGNED_SHORT_4_4_4_4; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3655 case RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: *glInternalFormat = GL_RGBA8; *glFormat = GL_RGBA; *glType = GL_UNSIGNED_BYTE; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3656 case RL_PIXELFORMAT_UNCOMPRESSED_R32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_R32F; *glFormat = GL_RED; *glType = GL_FLOAT; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3657 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGB32F; *glFormat = GL_RGB; *glType = GL_FLOAT; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3658 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGBA32F; *glFormat = GL_RGBA; *glType = GL_FLOAT; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3659 case RL_PIXELFORMAT_UNCOMPRESSED_R16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_R16F; *glFormat = GL_RED; *glType = GL_HALF_FLOAT; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3660 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGB16F; *glFormat = GL_RGB; *glType = GL_HALF_FLOAT; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3661 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGBA16F; *glFormat = GL_RGBA; *glType = GL_HALF_FLOAT; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3662 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3663 #if !defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3664 case RL_PIXELFORMAT_COMPRESSED_DXT1_RGB: if (RLGL.ExtSupported.texCompDXT) *glInternalFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3665 case RL_PIXELFORMAT_COMPRESSED_DXT1_RGBA: if (RLGL.ExtSupported.texCompDXT) *glInternalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3666 case RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA: if (RLGL.ExtSupported.texCompDXT) *glInternalFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3667 case RL_PIXELFORMAT_COMPRESSED_DXT5_RGBA: if (RLGL.ExtSupported.texCompDXT) *glInternalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3668 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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3669 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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3670 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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3671 case RL_PIXELFORMAT_COMPRESSED_PVRT_RGB: if (RLGL.ExtSupported.texCompPVRT) *glInternalFormat = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; break; // NOTE: Requires PowerVR GPU
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3672 case RL_PIXELFORMAT_COMPRESSED_PVRT_RGBA: if (RLGL.ExtSupported.texCompPVRT) *glInternalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; break; // NOTE: Requires PowerVR GPU
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3673 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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3674 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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3675 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3676 default: TRACELOG(RL_LOG_WARNING, "TEXTURE: Current format not supported (%i)", format); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3677 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3678 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3679
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3680 // Unload texture from GPU memory
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3681 void rlUnloadTexture(unsigned int id)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3682 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3683 glDeleteTextures(1, &id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3684 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3685
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3686 // Generate mipmap data for selected texture
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3687 // NOTE: Only supports GPU mipmap generation
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3688 void rlGenTextureMipmaps(unsigned int id, int width, int height, int format, int *mipmaps)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3689 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3690 if (!isGpuReady) { TRACELOG(RL_LOG_WARNING, "GL: GPU is not ready to load data, trying to load before InitWindow()?"); return; }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3691
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3692 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3693 glBindTexture(GL_TEXTURE_2D, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3694
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3695 // Check if texture is power-of-two (POT)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3696 bool texIsPOT = false;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3697
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3698 if (((width > 0) && ((width & (width - 1)) == 0)) &&
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3699 ((height > 0) && ((height & (height - 1)) == 0))) texIsPOT = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3700
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3701 if ((texIsPOT) || (RLGL.ExtSupported.texNPOT))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3702 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3703 //glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); // Hint for mipmaps generation algorithm: GL_FASTEST, GL_NICEST, GL_DONT_CARE
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3704 glGenerateMipmap(GL_TEXTURE_2D); // Generate mipmaps automatically
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3705
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3706 #define MIN(a,b) (((a)<(b))? (a):(b))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3707 #define MAX(a,b) (((a)>(b))? (a):(b))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3708
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3709 *mipmaps = 1 + (int)floor(log(MAX(width, height))/log(2));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3710 TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Mipmaps generated automatically, total: %i", id, *mipmaps);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3711 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3712 else TRACELOG(RL_LOG_WARNING, "TEXTURE: [ID %i] Failed to generate mipmaps", id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3713
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3714 glBindTexture(GL_TEXTURE_2D, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3715 #else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3716 TRACELOG(RL_LOG_WARNING, "TEXTURE: [ID %i] GPU mipmap generation not supported", id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3717 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3718 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3719
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3720 // Read texture pixel data
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3721 void *rlReadTexturePixels(unsigned int id, int width, int height, int format)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3722 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3723 void *pixels = NULL;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3724
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3725 #if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3726 glBindTexture(GL_TEXTURE_2D, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3727
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3728 // NOTE: Using texture id, some texture info can be retrieved (but not on OpenGL ES 2.0)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3729 // Possible texture info: GL_TEXTURE_RED_SIZE, GL_TEXTURE_GREEN_SIZE, GL_TEXTURE_BLUE_SIZE, GL_TEXTURE_ALPHA_SIZE
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3730 //int width, height, format;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3731 //glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3732 //glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3733 //glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &format);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3734
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3735 // 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
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3736 // Use glPixelStorei to modify padding with the GL_[UN]PACK_ALIGNMENT setting
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3737 // GL_PACK_ALIGNMENT affects operations that read from OpenGL memory (glReadPixels, glGetTexImage, etc.)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3738 // GL_UNPACK_ALIGNMENT affects operations that write to OpenGL memory (glTexImage, etc.)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3739 glPixelStorei(GL_PACK_ALIGNMENT, 1);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3740
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3741 unsigned int glInternalFormat, glFormat, glType;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3742 rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3743 unsigned int size = rlGetPixelDataSize(width, height, format);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3744
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3745 if ((glInternalFormat != 0) && (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3746 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3747 pixels = RL_CALLOC(size, 1);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3748 glGetTexImage(GL_TEXTURE_2D, 0, glFormat, glType, pixels);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3749 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3750 else TRACELOG(RL_LOG_WARNING, "TEXTURE: [ID %i] Data retrieval not suported for pixel format (%i)", id, format);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3751
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3752 glBindTexture(GL_TEXTURE_2D, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3753 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3754
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3755 #if defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3756 // glGetTexImage() is not available on OpenGL ES 2.0
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3757 // Texture width and height are required on OpenGL ES 2.0, there is no way to get it from texture id
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3758 // Two possible Options:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3759 // 1 - Bind texture to color fbo attachment and glReadPixels()
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3760 // 2 - Create an fbo, activate it, render quad with texture, glReadPixels()
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3761 // Using Option 1, care for texture format on retrieval
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3762 // NOTE: This behaviour could be conditioned by graphic driver...
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3763 unsigned int fboId = rlLoadFramebuffer();
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3764
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3765 glBindFramebuffer(GL_FRAMEBUFFER, fboId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3766 glBindTexture(GL_TEXTURE_2D, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3767
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3768 // Attach our texture to FBO
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3769 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, id, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3770
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3771 // Reading data as RGBA because FBO texture is configured as RGBA, despite binding another texture format
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3772 pixels = RL_CALLOC(rlGetPixelDataSize(width, height, RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8), 1);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3773 glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3774
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3775 glBindFramebuffer(GL_FRAMEBUFFER, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3776
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3777 // Clean up temporal fbo
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3778 rlUnloadFramebuffer(fboId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3779 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3780
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3781 return pixels;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3782 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3783
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3784 // Copy framebuffer pixel data to internal buffer
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3785 void rlCopyFramebuffer(int x, int y, int width, int height, int format, void *pixels)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3786 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3787 #if defined(GRAPHICS_API_OPENGL_SOFTWARE)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3788 unsigned int glInternalFormat, glFormat, glType;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3789 rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); // Get OpenGL texture format
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3790 swReadPixels(x, y, width, height, glFormat, glType, pixels);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3791 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3792 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3793
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3794 // Resize internal framebuffer
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3795 void rlResizeFramebuffer(int width, int height)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3796 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3797 #if defined(GRAPHICS_API_OPENGL_SOFTWARE)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3798 swResize(width, height);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3799 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3800 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3801
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3802 // Read screen pixel data (color buffer)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3803 unsigned char *rlReadScreenPixels(int width, int height)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3804 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3805 unsigned char *imgData = (unsigned char *)RL_CALLOC(width*height*4, sizeof(unsigned char));
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3806
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3807 // NOTE: glReadPixels() returns image flipped vertically -> (0,0) is the bottom left corner of the framebuffer
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3808 // WARNING: Getting alpha channel! Be careful, it can be transparent if not cleared properly!
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3809 glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, imgData);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3810
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3811 // Flip image vertically
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3812 // NOTE: Alpha value has already been applied to RGB in framebuffer, not needed anymore
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3813 for (int y = height - 1; y >= height/2; y--)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3814 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3815 for (int x = 0; x < (width*4); x += 4)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3816 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3817 unsigned int s = ((height - 1) - y)*width*4 + x;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3818 unsigned int e = y*width*4 + x;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3819
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3820 unsigned char r = imgData[s];
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3821 unsigned char g = imgData[s+1];
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3822 unsigned char b = imgData[s+2];
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3823
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3824 imgData[s] = imgData[e];
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3825 imgData[s+1] = imgData[e+1];
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3826 imgData[s+2] = imgData[e+2];
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3827 imgData[s+3] = 255; // Set alpha component value to 255 (no trasparent image retrieval)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3828
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3829 imgData[e] = r;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3830 imgData[e+1] = g;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3831 imgData[e+2] = b;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3832 imgData[e+3] = 255; // Ditto
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3833 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3834 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3835
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3836 return imgData; // NOTE: image data should be freed
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3837 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3838
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3839 // Framebuffer management (fbo)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3840 //-----------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3841 // Load a framebuffer to be used for rendering
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3842 // NOTE: No textures attached
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3843 unsigned int rlLoadFramebuffer(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3844 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3845 unsigned int fboId = 0;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3846 if (!isGpuReady) { TRACELOG(RL_LOG_WARNING, "GL: GPU is not ready to load data, trying to load before InitWindow()?"); return fboId; }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3847
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3848 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_SOFTWARE))
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3849 glGenFramebuffers(1, &fboId); // Create the framebuffer object
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3850 glBindFramebuffer(GL_FRAMEBUFFER, 0); // Unbind any framebuffer
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3851 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3852
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3853 return fboId;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3854 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3855
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3856 // Attach color buffer texture to a framebuffer object (unloads previous attachment)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3857 // NOTE: Attach type: 0-Color, 1-Depth renderbuffer, 2-Depth texture
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3858 void rlFramebufferAttach(unsigned int id, unsigned int texId, int attachType, int texType, int mipLevel)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3859 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3860 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_SOFTWARE))
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3861 glBindFramebuffer(GL_FRAMEBUFFER, id);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3862
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3863 switch (attachType)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3864 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3865 case RL_ATTACHMENT_COLOR_CHANNEL0:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3866 case RL_ATTACHMENT_COLOR_CHANNEL1:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3867 case RL_ATTACHMENT_COLOR_CHANNEL2:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3868 case RL_ATTACHMENT_COLOR_CHANNEL3:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3869 case RL_ATTACHMENT_COLOR_CHANNEL4:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3870 case RL_ATTACHMENT_COLOR_CHANNEL5:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3871 case RL_ATTACHMENT_COLOR_CHANNEL6:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3872 case RL_ATTACHMENT_COLOR_CHANNEL7:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3873 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3874 if (texType == RL_ATTACHMENT_TEXTURE2D) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + attachType, GL_TEXTURE_2D, texId, mipLevel);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3875 else if (texType == RL_ATTACHMENT_RENDERBUFFER) glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + attachType, GL_RENDERBUFFER, texId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3876 else if (texType >= RL_ATTACHMENT_CUBEMAP_POSITIVE_X) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + attachType, GL_TEXTURE_CUBE_MAP_POSITIVE_X + texType, texId, mipLevel);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3877 } break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3878 case RL_ATTACHMENT_DEPTH:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3879 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3880 if (texType == RL_ATTACHMENT_TEXTURE2D) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, texId, mipLevel);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3881 else if (texType == RL_ATTACHMENT_RENDERBUFFER) glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, texId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3882 } break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3883 case RL_ATTACHMENT_STENCIL:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3884 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3885 if (texType == RL_ATTACHMENT_TEXTURE2D) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, texId, mipLevel);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3886 else if (texType == RL_ATTACHMENT_RENDERBUFFER) glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, texId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3887 } break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3888 default: break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3889 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3890
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3891 glBindFramebuffer(GL_FRAMEBUFFER, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3892 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3893 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3894
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3895 // Verify render texture is complete
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3896 bool rlFramebufferComplete(unsigned int id)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3897 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3898 bool result = false;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3899
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3900 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_SOFTWARE))
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3901 glBindFramebuffer(GL_FRAMEBUFFER, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3902
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3903 GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3904
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3905 if (status != GL_FRAMEBUFFER_COMPLETE)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3906 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3907 switch (status)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3908 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3909 case GL_FRAMEBUFFER_UNSUPPORTED: TRACELOG(RL_LOG_WARNING, "FBO: [ID %i] Framebuffer is unsupported", id); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3910 case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: TRACELOG(RL_LOG_WARNING, "FBO: [ID %i] Framebuffer has incomplete attachment", id); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3911 #if defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3912 case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: TRACELOG(RL_LOG_WARNING, "FBO: [ID %i] Framebuffer has incomplete dimensions", id); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3913 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3914 case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: TRACELOG(RL_LOG_WARNING, "FBO: [ID %i] Framebuffer has a missing attachment", id); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3915 default: break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3916 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3917 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3918
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3919 glBindFramebuffer(GL_FRAMEBUFFER, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3920
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3921 result = (status == GL_FRAMEBUFFER_COMPLETE);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3922 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3923
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3924 return result;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3925 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3926
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3927 // Unload framebuffer from GPU memory
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3928 // NOTE: All attached textures/cubemaps/renderbuffers are also deleted
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3929 void rlUnloadFramebuffer(unsigned int id)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3930 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3931 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_SOFTWARE))
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3932 // Query depth attachment to automatically delete texture/renderbuffer
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3933 int depthType = 0;
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3934 glBindFramebuffer(GL_FRAMEBUFFER, id); // Bind framebuffer to query depth texture type
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3935 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &depthType);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3936
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3937 // WARNING: WebGL: INVALID_ENUM: getFramebufferAttachmentParameter: invalid parameter name
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3938 // REF: https://registry.khronos.org/webgl/specs/latest/1.0/
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3939 int depthId = 0;
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3940 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &depthId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3941
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3942 unsigned int depthIdU = (unsigned int)depthId;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3943 if (depthType == GL_RENDERBUFFER) glDeleteRenderbuffers(1, &depthIdU);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3944 else if (depthType == GL_TEXTURE) glDeleteTextures(1, &depthIdU);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3945
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3946 // NOTE: If a texture object is deleted while its image is attached to the *currently bound* framebuffer,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3947 // the texture image is automatically detached from the currently bound framebuffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3948
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3949 glBindFramebuffer(GL_FRAMEBUFFER, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3950 glDeleteFramebuffers(1, &id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3951
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3952 TRACELOG(RL_LOG_INFO, "FBO: [ID %i] Unloaded framebuffer from VRAM (GPU)", id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3953 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3954 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3955
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3956 // Vertex data management
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3957 //-----------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3958 // Load a new attributes buffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3959 unsigned int rlLoadVertexBuffer(const void *buffer, int size, bool dynamic)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3960 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3961 unsigned int id = 0;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3962 if (!isGpuReady) { TRACELOG(RL_LOG_WARNING, "GL: GPU is not ready to load data, trying to load before InitWindow()?"); return id; }
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3963
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3964 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3965 glGenBuffers(1, &id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3966 glBindBuffer(GL_ARRAY_BUFFER, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3967 glBufferData(GL_ARRAY_BUFFER, size, buffer, dynamic? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3968 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3969
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3970 return id;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3971 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3972
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3973 // Load a new attributes element buffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3974 unsigned int rlLoadVertexBufferElement(const void *buffer, int size, bool dynamic)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3975 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3976 unsigned int id = 0;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
3977 if (!isGpuReady) { TRACELOG(RL_LOG_WARNING, "GL: GPU is not ready to load data, trying to load before InitWindow()?"); return id; }
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3978
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3979 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3980 glGenBuffers(1, &id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3981 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3982 glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, buffer, dynamic? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3983 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3984
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3985 return id;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3986 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3987
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3988 // Enable vertex buffer (VBO)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3989 void rlEnableVertexBuffer(unsigned int id)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3990 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3991 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3992 glBindBuffer(GL_ARRAY_BUFFER, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3993 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3994 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3995
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3996 // Disable vertex buffer (VBO)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3997 void rlDisableVertexBuffer(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3998 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3999 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4000 glBindBuffer(GL_ARRAY_BUFFER, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4001 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4002 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4003
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4004 // Enable vertex buffer element (VBO element)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4005 void rlEnableVertexBufferElement(unsigned int id)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4006 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4007 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4008 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4009 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4010 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4011
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4012 // Disable vertex buffer element (VBO element)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4013 void rlDisableVertexBufferElement(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4014 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4015 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4016 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4017 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4018 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4019
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4020 // Update vertex buffer with new data
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4021 // NOTE: dataSize and offset must be provided in bytes
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4022 void rlUpdateVertexBuffer(unsigned int id, const void *data, int dataSize, int offset)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4023 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4024 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4025 glBindBuffer(GL_ARRAY_BUFFER, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4026 glBufferSubData(GL_ARRAY_BUFFER, offset, dataSize, data);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4027 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4028 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4029
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4030 // Update vertex buffer elements with new data
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4031 // NOTE: dataSize and offset must be provided in bytes
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4032 void rlUpdateVertexBufferElements(unsigned int id, const void *data, int dataSize, int offset)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4033 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4034 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4035 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4036 glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, offset, dataSize, data);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4037 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4038 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4039
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4040 // Enable vertex array object (VAO)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4041 bool rlEnableVertexArray(unsigned int vaoId)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4042 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4043 bool result = false;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4044 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4045 if (RLGL.ExtSupported.vao)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4046 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4047 glBindVertexArray(vaoId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4048 result = true;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4049 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4050 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4051 return result;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4052 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4053
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4054 // Disable vertex array object (VAO)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4055 void rlDisableVertexArray(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4056 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4057 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4058 if (RLGL.ExtSupported.vao) glBindVertexArray(0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4059 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4060 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4061
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4062 // Enable vertex attribute index
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4063 void rlEnableVertexAttribute(unsigned int index)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4064 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4065 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4066 glEnableVertexAttribArray(index);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4067 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4068 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4069
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4070 // Disable vertex attribute index
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4071 void rlDisableVertexAttribute(unsigned int index)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4072 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4073 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4074 glDisableVertexAttribArray(index);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4075 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4076 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4077
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4078 // Draw vertex array
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4079 void rlDrawVertexArray(int offset, int count)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4080 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4081 glDrawArrays(GL_TRIANGLES, offset, count);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4082 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4083
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4084 // Draw vertex array elements
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4085 void rlDrawVertexArrayElements(int offset, int count, const void *buffer)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4086 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4087 // NOTE: Added pointer math separately from function to avoid UBSAN complaining
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4088 unsigned short *bufferPtr = (unsigned short *)buffer;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4089 if (offset > 0) bufferPtr += offset;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4090
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4091 glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, (const unsigned short *)bufferPtr);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4092 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4093
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4094 // Draw vertex array instanced
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4095 void rlDrawVertexArrayInstanced(int offset, int count, int instances)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4096 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4097 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4098 glDrawArraysInstanced(GL_TRIANGLES, offset, count, instances);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4099 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4100 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4101
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4102 // Draw vertex array elements instanced
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4103 void rlDrawVertexArrayElementsInstanced(int offset, int count, const void *buffer, int instances)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4104 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4105 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4106 // NOTE: Added pointer math separately from function to avoid UBSAN complaining
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4107 unsigned short *bufferPtr = (unsigned short *)buffer;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4108 if (offset > 0) bufferPtr += offset;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4109
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4110 glDrawElementsInstanced(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, (const unsigned short *)bufferPtr, instances);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4111 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4112 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4113
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4114 // Enable vertex state pointer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4115 void rlEnableStatePointer(int vertexAttribType, void *buffer)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4116 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4117 #if defined(GRAPHICS_API_OPENGL_11)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4118 if (buffer != NULL) glEnableClientState(vertexAttribType);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4119 switch (vertexAttribType)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4120 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4121 case GL_VERTEX_ARRAY: glVertexPointer(3, GL_FLOAT, 0, buffer); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4122 case GL_TEXTURE_COORD_ARRAY: glTexCoordPointer(2, GL_FLOAT, 0, buffer); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4123 case GL_NORMAL_ARRAY: if (buffer != NULL) glNormalPointer(GL_FLOAT, 0, buffer); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4124 case GL_COLOR_ARRAY: if (buffer != NULL) glColorPointer(4, GL_UNSIGNED_BYTE, 0, buffer); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4125 //case GL_INDEX_ARRAY: if (buffer != NULL) glIndexPointer(GL_SHORT, 0, buffer); break; // Indexed colors
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4126 default: break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4127 }
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4128 #endif
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4129 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4130
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4131 // Disable vertex state pointer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4132 void rlDisableStatePointer(int vertexAttribType)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4133 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4134 #if defined(GRAPHICS_API_OPENGL_11)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4135 glDisableClientState(vertexAttribType);
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4136 #endif
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4137 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4138
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4139 // Load vertex array object (VAO)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4140 unsigned int rlLoadVertexArray(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4141 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4142 unsigned int vaoId = 0;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4143 if (!isGpuReady) { TRACELOG(RL_LOG_WARNING, "GL: GPU is not ready to load data, trying to load before InitWindow()?"); return vaoId; }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4144
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4145 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4146 if (RLGL.ExtSupported.vao) glGenVertexArrays(1, &vaoId);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4147 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4148
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4149 return vaoId;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4150 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4151
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4152 // Set vertex attribute
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4153 void rlSetVertexAttribute(unsigned int index, int compSize, int type, bool normalized, int stride, int offset)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4154 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4155 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4156 // NOTE: Data type could be: GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_INT, GL_UNSIGNED_INT
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4157 // Additional types (depends on OpenGL version or extensions):
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4158 // - GL_HALF_FLOAT, GL_FLOAT, GL_DOUBLE, GL_FIXED,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4159 // - GL_INT_2_10_10_10_REV, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_10F_11F_11F_REV
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4160
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4161 size_t offsetNative = offset;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4162 glVertexAttribPointer(index, compSize, type, normalized, stride, (void *)offsetNative);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4163 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4164 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4165
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4166 // Set vertex attribute divisor
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4167 void rlSetVertexAttributeDivisor(unsigned int index, int divisor)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4168 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4169 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4170 glVertexAttribDivisor(index, divisor);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4171 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4172 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4173
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4174 // Unload vertex array object (VAO)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4175 void rlUnloadVertexArray(unsigned int vaoId)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4176 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4177 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4178 if (RLGL.ExtSupported.vao)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4179 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4180 glBindVertexArray(0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4181 glDeleteVertexArrays(1, &vaoId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4182 TRACELOG(RL_LOG_INFO, "VAO: [ID %i] Unloaded vertex array data from VRAM (GPU)", vaoId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4183 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4184 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4185 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4186
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4187 // Unload vertex buffer (VBO)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4188 void rlUnloadVertexBuffer(unsigned int vboId)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4189 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4190 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4191 glDeleteBuffers(1, &vboId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4192 //TRACELOG(RL_LOG_INFO, "VBO: Unloaded vertex data from VRAM (GPU)");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4193 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4194 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4195
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4196 // Shaders management
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4197 //-----------------------------------------------------------------------------------------------
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4198 // Load (compile) shader and return shader id
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4199 unsigned int rlLoadShader(const char *code, int type)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4200 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4201 unsigned int shaderId = 0;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4202
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4203 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4204 shaderId = glCreateShader(type);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4205 glShaderSource(shaderId, 1, &code, NULL);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4206
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4207 GLint success = 0;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4208 glCompileShader(shaderId);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4209 glGetShaderiv(shaderId, GL_COMPILE_STATUS, &success);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4210
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4211 if (success == GL_FALSE)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4212 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4213 switch (type)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4214 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4215 case GL_VERTEX_SHADER: TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to compile vertex shader code", shaderId); break;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4216 case GL_FRAGMENT_SHADER: TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to compile fragment shader code", shaderId); break;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4217 //case GL_GEOMETRY_SHADER:
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4218 #if defined(GRAPHICS_API_OPENGL_43)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4219 case GL_COMPUTE_SHADER: TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to compile compute shader code", shaderId); break;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4220 #elif defined(GRAPHICS_API_OPENGL_33)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4221 case GL_COMPUTE_SHADER: TRACELOG(RL_LOG_WARNING, "SHADER: Compute shaders not enabled. Define GRAPHICS_API_OPENGL_43", shaderId); break;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4222 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4223 default: break;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4224 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4225
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4226 int maxLength = 0;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4227 glGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &maxLength);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4228
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4229 if (maxLength > 0)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4230 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4231 int length = 0;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4232 char *log = (char *)RL_CALLOC(maxLength, sizeof(char));
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4233 glGetShaderInfoLog(shaderId, maxLength, &length, log);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4234 TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Compile error: %s", shaderId, log);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4235 RL_FREE(log);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4236 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4237
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4238 // Unload object allocated by glCreateShader(),
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4239 // despite failing in the compilation process
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4240 glDeleteShader(shaderId);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4241 shaderId = 0;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4242 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4243 else
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4244 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4245 switch (type)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4246 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4247 case GL_VERTEX_SHADER: TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Vertex shader compiled successfully", shaderId); break;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4248 case GL_FRAGMENT_SHADER: TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Fragment shader compiled successfully", shaderId); break;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4249 //case GL_GEOMETRY_SHADER:
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4250 #if defined(GRAPHICS_API_OPENGL_43)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4251 case GL_COMPUTE_SHADER: TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Compute shader compiled successfully", shaderId); break;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4252 #elif defined(GRAPHICS_API_OPENGL_33)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4253 case GL_COMPUTE_SHADER: TRACELOG(RL_LOG_WARNING, "SHADER: Compute shaders not enabled. Define GRAPHICS_API_OPENGL_43", shaderId); break;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4254 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4255 default: break;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4256 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4257 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4258 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4259
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4260 return shaderId;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4261 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4262
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4263 // Load shader program from code strings
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4264 // NOTE: If shader string is NULL, using default vertex/fragment shaders
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4265 unsigned int rlLoadShaderProgram(const char *vsCode, const char *fsCode)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4266 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4267 unsigned int id = 0; // Shader program id
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4268 if (!isGpuReady) { TRACELOG(RL_LOG_WARNING, "GL: GPU is not ready to load data, trying to load before InitWindow()?"); return id; }
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4269
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4270 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4271 unsigned int vertexShaderId = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4272 unsigned int fragmentShaderId = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4273
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4274 // Compile vertex shader (if provided)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4275 // NOTE: If not vertex shader is provided, use default one
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4276 if (vsCode != NULL) vertexShaderId = rlLoadShader(vsCode, GL_VERTEX_SHADER);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4277 else vertexShaderId = RLGL.State.defaultVShaderId;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4278
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4279 // Compile fragment shader (if provided)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4280 // NOTE: If not vertex shader is provided, use default one
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4281 if (fsCode != NULL) fragmentShaderId = rlLoadShader(fsCode, GL_FRAGMENT_SHADER);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4282 else fragmentShaderId = RLGL.State.defaultFShaderId;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4283
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4284 // In case vertex and fragment shader are the default ones, no need to recompile, assign the default shader program id
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4285 if ((vertexShaderId == RLGL.State.defaultVShaderId) && (fragmentShaderId == RLGL.State.defaultFShaderId)) id = RLGL.State.defaultShaderId;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4286 else if ((vertexShaderId > 0) && (fragmentShaderId > 0))
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4287 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4288 // One of or both shader are new, a new shader program needs to be compiled
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4289 id = rlLoadShaderProgramEx(vertexShaderId, fragmentShaderId);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4290
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4291 // Detaching and deleting vertex/fragment shaders (if not default ones)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4292 // WARNING: Detach shader before deletion to make sure memory is freed
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4293 if (vertexShaderId != RLGL.State.defaultVShaderId)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4294 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4295 // WARNING: Shader program linkage could fail and returned id is 0
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4296 if (id > 0) glDetachShader(id, vertexShaderId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4297 glDeleteShader(vertexShaderId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4298 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4299 if (fragmentShaderId != RLGL.State.defaultFShaderId)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4300 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4301 // WARNING: Shader program linkage could fail and returned id is 0
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4302 if (id > 0) glDetachShader(id, fragmentShaderId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4303 glDeleteShader(fragmentShaderId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4304 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4305
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4306 // In case shader program loading failed, assign default shader
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4307 if (id == 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4308 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4309 // In case shader loading fails, reassigning default shader
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4310 TRACELOG(RL_LOG_WARNING, "SHADER: Failed to load custom shader code, using default shader");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4311 id = RLGL.State.defaultShaderId;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4312 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4313 /*
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4314 else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4315 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4316 // Get available shader uniforms
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4317 // NOTE: This information is useful for debug...
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4318 int uniformCount = -1;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4319 glGetProgramiv(id, GL_ACTIVE_UNIFORMS, &uniformCount);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4320
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4321 for (int i = 0; i < uniformCount; i++)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4322 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4323 int namelen = -1;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4324 int num = -1;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4325 char name[256] = { 0 }; // Assume no variable names longer than 256
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4326 GLenum type = GL_ZERO;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4327
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4328 // Get the name of the uniforms
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4329 glGetActiveUniform(id, i, sizeof(name) - 1, &namelen, &num, &type, name);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4330
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4331 name[namelen] = 0;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4332 TRACELOG(RL_LOG_DEBUG, "SHADER: [ID %i] Active uniform (%s) set at location: %i", id, name, glGetUniformLocation(id, name));
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4333 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4334 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4335 */
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4336 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4337 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4338
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4339 return id;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4340 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4341
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4342 // Load shader program from already loaded shader ids
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4343 unsigned int rlLoadShaderProgramEx(unsigned int vsId, unsigned int fsId)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4344 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4345 unsigned int programId = 0;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4346 if (!isGpuReady) { TRACELOG(RL_LOG_WARNING, "GL: GPU is not ready to load data, trying to load before InitWindow()?"); return programId; }
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4347
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4348 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4349 GLint success = 0;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4350 programId = glCreateProgram();
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4351
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4352 glAttachShader(programId, vsId);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4353 glAttachShader(programId, fsId);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4354
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4355 // Default attribute shader locations must be bound before linking
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4356 // NOTE: There is no problem with binding a generic attribute index to an attribute variable name
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4357 // that is never used; if some attrib name is no found on the shader, it locations becomes -1
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4358 glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION, RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4359 glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4360 glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL, RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4361 glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR, RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4362 glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT, RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4363 glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4364 glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCETRANSFORM, RL_DEFAULT_SHADER_ATTRIB_NAME_INSTANCETRANSFORM);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4365 glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEINDICES);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4366 glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4367
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4368 glLinkProgram(programId);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4369
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4370 // NOTE: All uniform variables are intitialised to 0 when a program links
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4371
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4372 glGetProgramiv(programId, GL_LINK_STATUS, &success);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4373
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4374 if (success == GL_FALSE)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4375 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4376 TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to link shader program", programId);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4377
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4378 int maxLength = 0;
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4379 glGetProgramiv(programId, GL_INFO_LOG_LENGTH, &maxLength);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4380
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4381 if (maxLength > 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4382 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4383 int length = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4384 char *log = (char *)RL_CALLOC(maxLength, sizeof(char));
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4385 glGetProgramInfoLog(programId, maxLength, &length, log);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4386 TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Link error: %s", programId, log);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4387 RL_FREE(log);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4388 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4389
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4390 glDeleteProgram(programId);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4391
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4392 programId = 0;
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4393 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4394 else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4395 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4396 // Get the size of compiled shader program (not available on OpenGL ES 2.0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4397 // NOTE: If GL_LINK_STATUS is GL_FALSE, program binary length is zero
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4398 //GLint binarySize = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4399 //glGetProgramiv(id, GL_PROGRAM_BINARY_LENGTH, &binarySize);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4400
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4401 TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Program shader loaded successfully", programId);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4402 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4403 #endif
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4404 return programId;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4405 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4406
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4407 // Load compute shader program
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4408 unsigned int rlLoadShaderProgramCompute(unsigned int csId)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4409 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4410 unsigned int programId = 0;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4411
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4412 #if defined(GRAPHICS_API_OPENGL_43)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4413 GLint success = 0;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4414 programId = glCreateProgram();
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4415
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4416 glAttachShader(programId, csId);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4417
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4418 glLinkProgram(programId);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4419
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4420 // NOTE: All uniform variables are intitialised to 0 when a program links
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4421
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4422 glGetProgramiv(programId, GL_LINK_STATUS, &success);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4423
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4424 if (success == GL_FALSE)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4425 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4426 TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to link compute shader program", programId);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4427
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4428 int maxLength = 0;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4429 glGetProgramiv(programId, GL_INFO_LOG_LENGTH, &maxLength);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4430
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4431 if (maxLength > 0)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4432 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4433 int length = 0;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4434 char *log = (char *)RL_CALLOC(maxLength, sizeof(char));
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4435 glGetProgramInfoLog(programId, maxLength, &length, log);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4436 TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Link error: %s", programId, log);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4437 RL_FREE(log);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4438 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4439
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4440 glDeleteProgram(programId);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4441
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4442 programId = 0;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4443 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4444 else
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4445 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4446 // Get the size of compiled shader program (not available on OpenGL ES 2.0)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4447 // NOTE: If GL_LINK_STATUS is GL_FALSE, program binary length is zero
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4448 //GLint binarySize = 0;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4449 //glGetProgramiv(id, GL_PROGRAM_BINARY_LENGTH, &binarySize);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4450
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4451 TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Compute shader program loaded successfully", programId);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4452 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4453 #else
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4454 TRACELOG(RL_LOG_WARNING, "SHADER: Compute shaders not supported, enable GRAPHICS_API_OPENGL_43");
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4455 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4456
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4457 return programId;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4458 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4459
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4460 // Delete shader
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4461 void rlUnloadShader(unsigned int id)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4462 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4463 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4464 glDeleteShader(id);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4465
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4466 TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Unloaded shader data from VRAM (GPU)", id);
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4467 #endif
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4468 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4469
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4470 // Unload shader program
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4471 void rlUnloadShaderProgram(unsigned int id)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4472 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4473 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4474 glDeleteProgram(id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4475
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4476 TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Unloaded shader program data from VRAM (GPU)", id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4477 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4478 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4479
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4480 // Get shader location uniform
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4481 // NOTE: First parameter refers to shader program id
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4482 int rlGetLocationUniform(unsigned int id, const char *uniformName)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4483 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4484 int location = -1;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4485 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4486 location = glGetUniformLocation(id, uniformName);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4487
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4488 //if (location == -1) TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to find shader uniform: %s", shaderId, uniformName);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4489 //else TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Shader uniform (%s) set at location: %i", shaderId, uniformName, location);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4490 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4491 return location;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4492 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4493
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4494 // Get shader location attribute
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4495 // NOTE: First parameter refers to shader program id
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4496 int rlGetLocationAttrib(unsigned int id, const char *attribName)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4497 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4498 int location = -1;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4499 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4500 location = glGetAttribLocation(id, attribName);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4501
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4502 //if (location == -1) TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to find shader attribute: %s", shaderId, attribName);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4503 //else TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Shader attribute (%s) set at location: %i", shaderId, attribName, location);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4504 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4505 return location;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4506 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4507
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4508 // Set shader value uniform
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4509 void rlSetUniform(int locIndex, const void *value, int uniformType, int count)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4510 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4511 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4512 switch (uniformType)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4513 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4514 case RL_SHADER_UNIFORM_FLOAT: glUniform1fv(locIndex, count, (float *)value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4515 case RL_SHADER_UNIFORM_VEC2: glUniform2fv(locIndex, count, (float *)value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4516 case RL_SHADER_UNIFORM_VEC3: glUniform3fv(locIndex, count, (float *)value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4517 case RL_SHADER_UNIFORM_VEC4: glUniform4fv(locIndex, count, (float *)value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4518 case RL_SHADER_UNIFORM_INT: glUniform1iv(locIndex, count, (int *)value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4519 case RL_SHADER_UNIFORM_IVEC2: glUniform2iv(locIndex, count, (int *)value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4520 case RL_SHADER_UNIFORM_IVEC3: glUniform3iv(locIndex, count, (int *)value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4521 case RL_SHADER_UNIFORM_IVEC4: glUniform4iv(locIndex, count, (int *)value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4522 #if !defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4523 case RL_SHADER_UNIFORM_UINT: glUniform1uiv(locIndex, count, (unsigned int *)value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4524 case RL_SHADER_UNIFORM_UIVEC2: glUniform2uiv(locIndex, count, (unsigned int *)value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4525 case RL_SHADER_UNIFORM_UIVEC3: glUniform3uiv(locIndex, count, (unsigned int *)value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4526 case RL_SHADER_UNIFORM_UIVEC4: glUniform4uiv(locIndex, count, (unsigned int *)value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4527 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4528 case RL_SHADER_UNIFORM_SAMPLER2D: glUniform1iv(locIndex, count, (int *)value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4529 default: TRACELOG(RL_LOG_WARNING, "SHADER: Failed to set uniform value, data type not recognized");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4530 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4531 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4532 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4533
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4534 // Set shader value attribute
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4535 void rlSetVertexAttributeDefault(int locIndex, const void *value, int attribType, int count)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4536 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4537 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4538 switch (attribType)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4539 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4540 case RL_SHADER_ATTRIB_FLOAT: if (count == 1) glVertexAttrib1fv(locIndex, (float *)value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4541 case RL_SHADER_ATTRIB_VEC2: if (count == 2) glVertexAttrib2fv(locIndex, (float *)value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4542 case RL_SHADER_ATTRIB_VEC3: if (count == 3) glVertexAttrib3fv(locIndex, (float *)value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4543 case RL_SHADER_ATTRIB_VEC4: if (count == 4) glVertexAttrib4fv(locIndex, (float *)value); break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4544 default: TRACELOG(RL_LOG_WARNING, "SHADER: Failed to set attrib default value, data type not recognized");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4545 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4546 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4547 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4548
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4549 // Set shader value uniform matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4550 void rlSetUniformMatrix(int locIndex, Matrix mat)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4551 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4552 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4553 glUniformMatrix4fv(locIndex, 1, false, rlMatrixToFloat(mat));
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4554 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4555 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4556
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4557 // Set shader value uniform matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4558 void rlSetUniformMatrices(int locIndex, const Matrix *matrices, int count)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4559 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4560 #if defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4561 glUniformMatrix4fv(locIndex, count, true, (const float *)matrices);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4562 #elif defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4563 // WARNING: WebGL does not support Matrix transpose ("true" parameter)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4564 // REF: https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/uniformMatrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4565 glUniformMatrix4fv(locIndex, count, false, (const float *)matrices);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4566 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4567 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4568
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4569 // Set shader value uniform sampler
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4570 void rlSetUniformSampler(int locIndex, unsigned int textureId)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4571 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4572 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4573 // Check if texture is already active
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4574 for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4575 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4576 if (RLGL.State.activeTextureId[i] == textureId)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4577 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4578 glUniform1i(locIndex, 1 + i);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4579 return;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4580 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4581 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4582
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4583 // Register a new active texture for the internal batch system
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4584 // NOTE: Default texture is always activated as GL_TEXTURE0
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4585 for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4586 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4587 if (RLGL.State.activeTextureId[i] == 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4588 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4589 glUniform1i(locIndex, 1 + i); // Activate new texture unit
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4590 RLGL.State.activeTextureId[i] = textureId; // Save texture id for binding on drawing
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4591 break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4592 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4593 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4594 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4595 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4596
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4597 // Set shader currently active (id and locations)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4598 void rlSetShader(unsigned int id, int *locs)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4599 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4600 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4601 if (RLGL.State.currentShaderId != id)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4602 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4603 rlDrawRenderBatch(RLGL.currentBatch);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4604 RLGL.State.currentShaderId = id;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4605 RLGL.State.currentShaderLocs = locs;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4606 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4607 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4608 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4609
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4610 // Dispatch compute shader (equivalent to *draw* for graphics pilepine)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4611 void rlComputeShaderDispatch(unsigned int groupX, unsigned int groupY, unsigned int groupZ)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4612 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4613 #if defined(GRAPHICS_API_OPENGL_43)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4614 glDispatchCompute(groupX, groupY, groupZ);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4615 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4616 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4617
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4618 // Load shader storage buffer object (SSBO)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4619 unsigned int rlLoadShaderBuffer(unsigned int size, const void *data, int usageHint)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4620 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4621 unsigned int ssbo = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4622
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4623 #if defined(GRAPHICS_API_OPENGL_43)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4624 glGenBuffers(1, &ssbo);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4625 glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4626 glBufferData(GL_SHADER_STORAGE_BUFFER, size, data, usageHint? usageHint : RL_STREAM_COPY);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4627 if (data == NULL) glClearBufferData(GL_SHADER_STORAGE_BUFFER, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, NULL); // Clear buffer data to 0
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4628 glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4629 #else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4630 TRACELOG(RL_LOG_WARNING, "SSBO: SSBO not enabled. Define GRAPHICS_API_OPENGL_43");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4631 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4632
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4633 return ssbo;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4634 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4635
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4636 // Unload shader storage buffer object (SSBO)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4637 void rlUnloadShaderBuffer(unsigned int ssboId)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4638 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4639 #if defined(GRAPHICS_API_OPENGL_43)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4640 glDeleteBuffers(1, &ssboId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4641 #else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4642 TRACELOG(RL_LOG_WARNING, "SSBO: SSBO not enabled. Define GRAPHICS_API_OPENGL_43");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4643 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4644 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4645
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4646 // Update SSBO buffer data
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4647 void rlUpdateShaderBuffer(unsigned int id, const void *data, unsigned int dataSize, unsigned int offset)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4648 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4649 #if defined(GRAPHICS_API_OPENGL_43)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4650 glBindBuffer(GL_SHADER_STORAGE_BUFFER, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4651 glBufferSubData(GL_SHADER_STORAGE_BUFFER, offset, dataSize, data);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4652 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4653 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4654
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4655 // Get SSBO buffer size
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4656 unsigned int rlGetShaderBufferSize(unsigned int id)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4657 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4658 unsigned int result = 0;
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4659 #if defined(GRAPHICS_API_OPENGL_43)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4660 GLint64 size = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4661 glBindBuffer(GL_SHADER_STORAGE_BUFFER, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4662 glGetBufferParameteri64v(GL_SHADER_STORAGE_BUFFER, GL_BUFFER_SIZE, &size);
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4663 if (size > 0) result = (unsigned int)size;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4664 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4665 return result;
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4666 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4667
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4668 // Read SSBO buffer data (GPU->CPU)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4669 void rlReadShaderBuffer(unsigned int id, void *dest, unsigned int count, unsigned int offset)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4670 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4671 #if defined(GRAPHICS_API_OPENGL_43)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4672 glBindBuffer(GL_SHADER_STORAGE_BUFFER, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4673 glGetBufferSubData(GL_SHADER_STORAGE_BUFFER, offset, count, dest);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4674 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4675 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4676
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4677 // Bind SSBO buffer
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4678 void rlBindShaderBuffer(unsigned int id, unsigned int index)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4679 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4680 #if defined(GRAPHICS_API_OPENGL_43)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4681 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, index, id);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4682 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4683 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4684
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4685 // Copy SSBO buffer data
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4686 void rlCopyShaderBuffer(unsigned int destId, unsigned int srcId, unsigned int destOffset, unsigned int srcOffset, unsigned int count)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4687 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4688 #if defined(GRAPHICS_API_OPENGL_43)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4689 glBindBuffer(GL_COPY_READ_BUFFER, srcId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4690 glBindBuffer(GL_COPY_WRITE_BUFFER, destId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4691 glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, srcOffset, destOffset, count);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4692 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4693 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4694
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4695 // Bind image texture
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4696 void rlBindImageTexture(unsigned int id, unsigned int index, int format, bool readonly)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4697 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4698 #if defined(GRAPHICS_API_OPENGL_43)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4699 unsigned int glInternalFormat = 0, glFormat = 0, glType = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4700
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4701 rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4702 glBindImageTexture(index, id, 0, 0, 0, readonly? GL_READ_ONLY : GL_READ_WRITE, glInternalFormat);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4703 #else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4704 TRACELOG(RL_LOG_WARNING, "TEXTURE: Image texture binding not enabled. Define GRAPHICS_API_OPENGL_43");
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4705 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4706 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4707
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4708 // Matrix state management
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4709 //-----------------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4710 // Get internal modelview matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4711 Matrix rlGetMatrixModelview(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4712 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4713 Matrix matrix = rlMatrixIdentity();
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4714 #if defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4715 float mat[16];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4716 glGetFloatv(GL_MODELVIEW_MATRIX, mat);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4717 matrix.m0 = mat[0];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4718 matrix.m1 = mat[1];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4719 matrix.m2 = mat[2];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4720 matrix.m3 = mat[3];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4721 matrix.m4 = mat[4];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4722 matrix.m5 = mat[5];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4723 matrix.m6 = mat[6];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4724 matrix.m7 = mat[7];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4725 matrix.m8 = mat[8];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4726 matrix.m9 = mat[9];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4727 matrix.m10 = mat[10];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4728 matrix.m11 = mat[11];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4729 matrix.m12 = mat[12];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4730 matrix.m13 = mat[13];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4731 matrix.m14 = mat[14];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4732 matrix.m15 = mat[15];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4733 #else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4734 matrix = RLGL.State.modelview;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4735 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4736 return matrix;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4737 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4738
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4739 // Get internal projection matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4740 Matrix rlGetMatrixProjection(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4741 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4742 #if defined(GRAPHICS_API_OPENGL_11)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4743 float mat[16];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4744 glGetFloatv(GL_PROJECTION_MATRIX,mat);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4745 Matrix m;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4746 m.m0 = mat[0];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4747 m.m1 = mat[1];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4748 m.m2 = mat[2];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4749 m.m3 = mat[3];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4750 m.m4 = mat[4];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4751 m.m5 = mat[5];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4752 m.m6 = mat[6];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4753 m.m7 = mat[7];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4754 m.m8 = mat[8];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4755 m.m9 = mat[9];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4756 m.m10 = mat[10];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4757 m.m11 = mat[11];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4758 m.m12 = mat[12];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4759 m.m13 = mat[13];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4760 m.m14 = mat[14];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4761 m.m15 = mat[15];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4762 return m;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4763 #else
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4764 return RLGL.State.projection;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4765 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4766 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4767
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4768 // Get internal accumulated transform matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4769 Matrix rlGetMatrixTransform(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4770 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4771 Matrix mat = rlMatrixIdentity();
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4772 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4773 // TODO: Consider possible transform matrices in the RLGL.State.stack
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4774 //Matrix matStackTransform = rlMatrixIdentity();
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4775 //for (int i = RLGL.State.stackCounter; i > 0; i--) matStackTransform = rlMatrixMultiply(RLGL.State.stack[i], matStackTransform);
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4776
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4777 mat = RLGL.State.transform;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4778 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4779 return mat;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4780 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4781
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4782 // Get internal projection matrix for stereo render (selected eye)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4783 Matrix rlGetMatrixProjectionStereo(int eye)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4784 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4785 Matrix mat = rlMatrixIdentity();
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4786 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4787 mat = RLGL.State.projectionStereo[eye];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4788 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4789 return mat;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4790 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4791
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4792 // Get internal view offset matrix for stereo render (selected eye)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4793 Matrix rlGetMatrixViewOffsetStereo(int eye)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4794 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4795 Matrix mat = rlMatrixIdentity();
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4796 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4797 mat = RLGL.State.viewOffsetStereo[eye];
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4798 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4799 return mat;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4800 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4801
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4802 // Set a custom modelview matrix (replaces internal modelview matrix)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4803 void rlSetMatrixModelview(Matrix view)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4804 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4805 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4806 RLGL.State.modelview = view;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4807 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4808 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4809
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4810 // Set a custom projection matrix (replaces internal projection matrix)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4811 void rlSetMatrixProjection(Matrix projection)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4812 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4813 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4814 RLGL.State.projection = projection;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4815 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4816 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4817
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4818 // Set eyes projection matrices for stereo rendering
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4819 void rlSetMatrixProjectionStereo(Matrix right, Matrix left)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4820 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4821 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4822 RLGL.State.projectionStereo[0] = right;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4823 RLGL.State.projectionStereo[1] = left;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4824 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4825 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4826
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4827 // Set eyes view offsets matrices for stereo rendering
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4828 void rlSetMatrixViewOffsetStereo(Matrix right, Matrix left)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4829 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4830 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4831 RLGL.State.viewOffsetStereo[0] = right;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4832 RLGL.State.viewOffsetStereo[1] = left;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4833 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4834 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4835
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4836 // Load and draw a quad in NDC
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4837 void rlLoadDrawQuad(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4838 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4839 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4840 unsigned int quadVAO = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4841 unsigned int quadVBO = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4842
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4843 float vertices[] = {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4844 // Positions Texcoords
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4845 -1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4846 -1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4847 1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4848 1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4849 };
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4850
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4851 // Gen VAO to contain VBO
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4852 glGenVertexArrays(1, &quadVAO);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4853 glBindVertexArray(quadVAO);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4854
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4855 // Gen and fill vertex buffer (VBO)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4856 glGenBuffers(1, &quadVBO);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4857 glBindBuffer(GL_ARRAY_BUFFER, quadVBO);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4858 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), &vertices, GL_STATIC_DRAW);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4859
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4860 // Bind vertex attributes (position, texcoords)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4861 glEnableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4862 glVertexAttribPointer(RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION, 3, GL_FLOAT, GL_FALSE, 5*sizeof(float), (void *)0); // Positions
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4863 glEnableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4864 glVertexAttribPointer(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 5*sizeof(float), (void *)(3*sizeof(float))); // Texcoords
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4865
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4866 // Draw quad
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4867 glBindVertexArray(quadVAO);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4868 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4869 glBindVertexArray(0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4870
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4871 // Delete buffers (VBO and VAO)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4872 glDeleteBuffers(1, &quadVBO);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4873 glDeleteVertexArrays(1, &quadVAO);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4874 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4875 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4876
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4877 // Load and draw a cube in NDC
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4878 void rlLoadDrawCube(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4879 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4880 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4881 unsigned int cubeVAO = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4882 unsigned int cubeVBO = 0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4883
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4884 float vertices[] = {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4885 // Positions Normals Texcoords
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4886 -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4887 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4888 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4889 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4890 -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4891 -1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4892 -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4893 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4894 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4895 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4896 -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4897 -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4898 -1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4899 -1.0f, 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4900 -1.0f, -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4901 -1.0f, -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4902 -1.0f, -1.0f, 1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4903 -1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4904 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4905 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4906 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4907 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4908 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4909 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4910 -1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4911 1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4912 1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4913 1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4914 -1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4915 -1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4916 -1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4917 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4918 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4919 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4920 -1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4921 -1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4922 };
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4923
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4924 // Gen VAO to contain VBO
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4925 glGenVertexArrays(1, &cubeVAO);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4926 glBindVertexArray(cubeVAO);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4927
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4928 // Gen and fill vertex buffer (VBO)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4929 glGenBuffers(1, &cubeVBO);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4930 glBindBuffer(GL_ARRAY_BUFFER, cubeVBO);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4931 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4932
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4933 // Bind vertex attributes (position, normals, texcoords)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4934 glBindVertexArray(cubeVAO);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4935 glEnableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4936 glVertexAttribPointer(RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION, 3, GL_FLOAT, GL_FALSE, 8*sizeof(float), (void *)0); // Positions
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4937 glEnableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4938 glVertexAttribPointer(RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL, 3, GL_FLOAT, GL_FALSE, 8*sizeof(float), (void *)(3*sizeof(float))); // Normals
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4939 glEnableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4940 glVertexAttribPointer(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 8*sizeof(float), (void *)(6*sizeof(float))); // Texcoords
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4941 glBindBuffer(GL_ARRAY_BUFFER, 0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4942 glBindVertexArray(0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4943
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4944 // Draw cube
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4945 glBindVertexArray(cubeVAO);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4946 glDrawArrays(GL_TRIANGLES, 0, 36);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4947 glBindVertexArray(0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4948
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4949 // Delete VBO and VAO
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4950 glDeleteBuffers(1, &cubeVBO);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4951 glDeleteVertexArrays(1, &cubeVAO);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4952 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4953 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4954
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4955 // Get name string for pixel format
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4956 const char *rlGetPixelFormatName(unsigned int format)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4957 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4958 switch (format)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4959 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4960 case RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE: return "GRAYSCALE"; break; // 8 bit per pixel (no alpha)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4961 case RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA: return "GRAY_ALPHA"; break; // 8*2 bpp (2 channels)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4962 case RL_PIXELFORMAT_UNCOMPRESSED_R5G6B5: return "R5G6B5"; break; // 16 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4963 case RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8: return "R8G8B8"; break; // 24 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4964 case RL_PIXELFORMAT_UNCOMPRESSED_R5G5B5A1: return "R5G5B5A1"; break; // 16 bpp (1 bit alpha)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4965 case RL_PIXELFORMAT_UNCOMPRESSED_R4G4B4A4: return "R4G4B4A4"; break; // 16 bpp (4 bit alpha)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4966 case RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: return "R8G8B8A8"; break; // 32 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4967 case RL_PIXELFORMAT_UNCOMPRESSED_R32: return "R32"; break; // 32 bpp (1 channel - float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4968 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32: return "R32G32B32"; break; // 32*3 bpp (3 channels - float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4969 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: return "R32G32B32A32"; break; // 32*4 bpp (4 channels - float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4970 case RL_PIXELFORMAT_UNCOMPRESSED_R16: return "R16"; break; // 16 bpp (1 channel - half float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4971 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: return "R16G16B16"; break; // 16*3 bpp (3 channels - half float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4972 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: return "R16G16B16A16"; break; // 16*4 bpp (4 channels - half float)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4973 case RL_PIXELFORMAT_COMPRESSED_DXT1_RGB: return "DXT1_RGB"; break; // 4 bpp (no alpha)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4974 case RL_PIXELFORMAT_COMPRESSED_DXT1_RGBA: return "DXT1_RGBA"; break; // 4 bpp (1 bit alpha)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4975 case RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA: return "DXT3_RGBA"; break; // 8 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4976 case RL_PIXELFORMAT_COMPRESSED_DXT5_RGBA: return "DXT5_RGBA"; break; // 8 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4977 case RL_PIXELFORMAT_COMPRESSED_ETC1_RGB: return "ETC1_RGB"; break; // 4 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4978 case RL_PIXELFORMAT_COMPRESSED_ETC2_RGB: return "ETC2_RGB"; break; // 4 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4979 case RL_PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA: return "ETC2_RGBA"; break; // 8 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4980 case RL_PIXELFORMAT_COMPRESSED_PVRT_RGB: return "PVRT_RGB"; break; // 4 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4981 case RL_PIXELFORMAT_COMPRESSED_PVRT_RGBA: return "PVRT_RGBA"; break; // 4 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4982 case RL_PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA: return "ASTC_4x4_RGBA"; break; // 8 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4983 case RL_PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA: return "ASTC_8x8_RGBA"; break; // 2 bpp
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4984 default: return "UNKNOWN"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4985 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4986 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4987
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4988 //----------------------------------------------------------------------------------
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
4989 // Module Functions Definition
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4990 //----------------------------------------------------------------------------------
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4991 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4992 // Load default shader (just vertex positioning and texture coloring)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4993 // NOTE: This shader program is used for internal buffers
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4994 // NOTE: Loaded: RLGL.State.defaultShaderId, RLGL.State.defaultShaderLocs
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4995 static void rlLoadShaderDefault(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4996 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4997 RLGL.State.defaultShaderLocs = (int *)RL_CALLOC(RL_MAX_SHADER_LOCATIONS, sizeof(int));
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4998
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4999 // NOTE: All locations must be reseted to -1 (no location)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5000 for (int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++) RLGL.State.defaultShaderLocs[i] = -1;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5001
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5002 // Vertex shader directly defined, no external file required
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5003 const char *defaultVShaderCode =
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5004 #if defined(GRAPHICS_API_OPENGL_21)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5005 "#version 120 \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5006 "attribute vec3 vertexPosition; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5007 "attribute vec2 vertexTexCoord; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5008 "attribute vec4 vertexColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5009 "varying vec2 fragTexCoord; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5010 "varying vec4 fragColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5011 #elif defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5012 "#version 330 \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5013 "in vec3 vertexPosition; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5014 "in vec2 vertexTexCoord; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5015 "in vec4 vertexColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5016 "out vec2 fragTexCoord; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5017 "out vec4 fragColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5018 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5019
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5020 #if defined(GRAPHICS_API_OPENGL_ES3)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5021 "#version 300 es \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5022 "precision mediump float; \n" // Precision required for OpenGL ES3 (WebGL 2) (on some browsers)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5023 "in vec3 vertexPosition; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5024 "in vec2 vertexTexCoord; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5025 "in vec4 vertexColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5026 "out vec2 fragTexCoord; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5027 "out vec4 fragColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5028 #elif defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5029 "#version 100 \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5030 "precision mediump float; \n" // Precision required for OpenGL ES2 (WebGL) (on some browsers)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5031 "attribute vec3 vertexPosition; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5032 "attribute vec2 vertexTexCoord; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5033 "attribute vec4 vertexColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5034 "varying vec2 fragTexCoord; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5035 "varying vec4 fragColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5036 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5037
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5038 "uniform mat4 mvp; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5039 "void main() \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5040 "{ \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5041 " fragTexCoord = vertexTexCoord; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5042 " fragColor = vertexColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5043 " gl_Position = mvp*vec4(vertexPosition, 1.0); \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5044 "} \n";
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5045
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5046 // Fragment shader directly defined, no external file required
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5047 const char *defaultFShaderCode =
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5048 #if defined(GRAPHICS_API_OPENGL_21)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5049 "#version 120 \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5050 "varying vec2 fragTexCoord; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5051 "varying vec4 fragColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5052 "uniform sampler2D texture0; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5053 "uniform vec4 colDiffuse; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5054 "void main() \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5055 "{ \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5056 " vec4 texelColor = texture2D(texture0, fragTexCoord); \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5057 " gl_FragColor = texelColor*colDiffuse*fragColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5058 "} \n";
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5059 #elif defined(GRAPHICS_API_OPENGL_33)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5060 "#version 330 \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5061 "in vec2 fragTexCoord; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5062 "in vec4 fragColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5063 "out vec4 finalColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5064 "uniform sampler2D texture0; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5065 "uniform vec4 colDiffuse; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5066 "void main() \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5067 "{ \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5068 " vec4 texelColor = texture(texture0, fragTexCoord); \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5069 " finalColor = texelColor*colDiffuse*fragColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5070 "} \n";
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5071 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5072
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5073 #if defined(GRAPHICS_API_OPENGL_ES3)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5074 "#version 300 es \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5075 "precision mediump float; \n" // Precision required for OpenGL ES3 (WebGL 2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5076 "in vec2 fragTexCoord; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5077 "in vec4 fragColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5078 "out vec4 finalColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5079 "uniform sampler2D texture0; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5080 "uniform vec4 colDiffuse; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5081 "void main() \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5082 "{ \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5083 " vec4 texelColor = texture(texture0, fragTexCoord); \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5084 " finalColor = texelColor*colDiffuse*fragColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5085 "} \n";
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5086 #elif defined(GRAPHICS_API_OPENGL_ES2)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5087 "#version 100 \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5088 "precision mediump float; \n" // Precision required for OpenGL ES2 (WebGL)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5089 "varying vec2 fragTexCoord; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5090 "varying vec4 fragColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5091 "uniform sampler2D texture0; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5092 "uniform vec4 colDiffuse; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5093 "void main() \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5094 "{ \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5095 " vec4 texelColor = texture2D(texture0, fragTexCoord); \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5096 " gl_FragColor = texelColor*colDiffuse*fragColor; \n"
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5097 "} \n";
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5098 #endif
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5099
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5100 // NOTE: Compiled vertex/fragment shaders are not deleted,
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5101 // they are kept for re-use as default shaders in case some shader loading fails
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5102 RLGL.State.defaultVShaderId = rlLoadShader(defaultVShaderCode, GL_VERTEX_SHADER); // Compile default vertex shader
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5103 RLGL.State.defaultFShaderId = rlLoadShader(defaultFShaderCode, GL_FRAGMENT_SHADER); // Compile default fragment shader
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5104
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5105 RLGL.State.defaultShaderId = rlLoadShaderProgramEx(RLGL.State.defaultVShaderId, RLGL.State.defaultFShaderId);
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5106
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5107 if (RLGL.State.defaultShaderId > 0)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5108 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5109 TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Default shader loaded successfully", RLGL.State.defaultShaderId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5110
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5111 // Set default shader locations: attributes locations
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5112 RLGL.State.defaultShaderLocs[RL_SHADER_LOC_VERTEX_POSITION] = glGetAttribLocation(RLGL.State.defaultShaderId, RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5113 RLGL.State.defaultShaderLocs[RL_SHADER_LOC_VERTEX_TEXCOORD01] = glGetAttribLocation(RLGL.State.defaultShaderId, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5114 RLGL.State.defaultShaderLocs[RL_SHADER_LOC_VERTEX_COLOR] = glGetAttribLocation(RLGL.State.defaultShaderId, RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5115
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5116 // Set default shader locations: uniform locations
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5117 RLGL.State.defaultShaderLocs[RL_SHADER_LOC_MATRIX_MVP] = glGetUniformLocation(RLGL.State.defaultShaderId, RL_DEFAULT_SHADER_UNIFORM_NAME_MVP);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5118 RLGL.State.defaultShaderLocs[RL_SHADER_LOC_COLOR_DIFFUSE] = glGetUniformLocation(RLGL.State.defaultShaderId, RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5119 RLGL.State.defaultShaderLocs[RL_SHADER_LOC_MAP_DIFFUSE] = glGetUniformLocation(RLGL.State.defaultShaderId, RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5120 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5121 else TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to load default shader", RLGL.State.defaultShaderId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5122 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5123
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5124 // Unload default shader
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5125 // NOTE: Unloads: RLGL.State.defaultShaderId, RLGL.State.defaultShaderLocs
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5126 static void rlUnloadShaderDefault(void)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5127 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5128 glUseProgram(0);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5129
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5130 glDetachShader(RLGL.State.defaultShaderId, RLGL.State.defaultVShaderId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5131 glDetachShader(RLGL.State.defaultShaderId, RLGL.State.defaultFShaderId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5132 glDeleteShader(RLGL.State.defaultVShaderId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5133 glDeleteShader(RLGL.State.defaultFShaderId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5134
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5135 glDeleteProgram(RLGL.State.defaultShaderId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5136
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5137 RL_FREE(RLGL.State.defaultShaderLocs);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5138
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5139 TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Default shader unloaded successfully", RLGL.State.defaultShaderId);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5140 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5141
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5142 #if RLGL_SHOW_GL_DETAILS_INFO
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5143 // Get compressed format official GL identifier name
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5144 static const char *rlGetCompressedFormatName(int format)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5145 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5146 switch (format)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5147 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5148 // GL_EXT_texture_compression_s3tc
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5149 case 0x83F0: return "GL_COMPRESSED_RGB_S3TC_DXT1_EXT"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5150 case 0x83F1: return "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5151 case 0x83F2: return "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5152 case 0x83F3: return "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5153 // GL_3DFX_texture_compression_FXT1
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5154 case 0x86B0: return "GL_COMPRESSED_RGB_FXT1_3DFX"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5155 case 0x86B1: return "GL_COMPRESSED_RGBA_FXT1_3DFX"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5156 // GL_IMG_texture_compression_pvrtc
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5157 case 0x8C00: return "GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5158 case 0x8C01: return "GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5159 case 0x8C02: return "GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5160 case 0x8C03: return "GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5161 // GL_OES_compressed_ETC1_RGB8_texture
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5162 case 0x8D64: return "GL_ETC1_RGB8_OES"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5163 // GL_ARB_texture_compression_rgtc
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5164 case 0x8DBB: return "GL_COMPRESSED_RED_RGTC1"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5165 case 0x8DBC: return "GL_COMPRESSED_SIGNED_RED_RGTC1"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5166 case 0x8DBD: return "GL_COMPRESSED_RG_RGTC2"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5167 case 0x8DBE: return "GL_COMPRESSED_SIGNED_RG_RGTC2"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5168 // GL_ARB_texture_compression_bptc
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5169 case 0x8E8C: return "GL_COMPRESSED_RGBA_BPTC_UNORM_ARB"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5170 case 0x8E8D: return "GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5171 case 0x8E8E: return "GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5172 case 0x8E8F: return "GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5173 // GL_ARB_ES3_compatibility
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5174 case 0x9274: return "GL_COMPRESSED_RGB8_ETC2"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5175 case 0x9275: return "GL_COMPRESSED_SRGB8_ETC2"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5176 case 0x9276: return "GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5177 case 0x9277: return "GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5178 case 0x9278: return "GL_COMPRESSED_RGBA8_ETC2_EAC"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5179 case 0x9279: return "GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5180 case 0x9270: return "GL_COMPRESSED_R11_EAC"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5181 case 0x9271: return "GL_COMPRESSED_SIGNED_R11_EAC"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5182 case 0x9272: return "GL_COMPRESSED_RG11_EAC"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5183 case 0x9273: return "GL_COMPRESSED_SIGNED_RG11_EAC"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5184 // GL_KHR_texture_compression_astc_hdr
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5185 case 0x93B0: return "GL_COMPRESSED_RGBA_ASTC_4x4_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5186 case 0x93B1: return "GL_COMPRESSED_RGBA_ASTC_5x4_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5187 case 0x93B2: return "GL_COMPRESSED_RGBA_ASTC_5x5_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5188 case 0x93B3: return "GL_COMPRESSED_RGBA_ASTC_6x5_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5189 case 0x93B4: return "GL_COMPRESSED_RGBA_ASTC_6x6_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5190 case 0x93B5: return "GL_COMPRESSED_RGBA_ASTC_8x5_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5191 case 0x93B6: return "GL_COMPRESSED_RGBA_ASTC_8x6_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5192 case 0x93B7: return "GL_COMPRESSED_RGBA_ASTC_8x8_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5193 case 0x93B8: return "GL_COMPRESSED_RGBA_ASTC_10x5_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5194 case 0x93B9: return "GL_COMPRESSED_RGBA_ASTC_10x6_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5195 case 0x93BA: return "GL_COMPRESSED_RGBA_ASTC_10x8_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5196 case 0x93BB: return "GL_COMPRESSED_RGBA_ASTC_10x10_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5197 case 0x93BC: return "GL_COMPRESSED_RGBA_ASTC_12x10_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5198 case 0x93BD: return "GL_COMPRESSED_RGBA_ASTC_12x12_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5199 case 0x93D0: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5200 case 0x93D1: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5201 case 0x93D2: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5202 case 0x93D3: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5203 case 0x93D4: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5204 case 0x93D5: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5205 case 0x93D6: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5206 case 0x93D7: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5207 case 0x93D8: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5208 case 0x93D9: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5209 case 0x93DA: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5210 case 0x93DB: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5211 case 0x93DC: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5212 case 0x93DD: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5213 default: return "GL_COMPRESSED_UNKNOWN"; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5214 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5215 }
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5216 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5217
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5218 #endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5219
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5220 // Get pixel data size in bytes (image or texture)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5221 // NOTE: Size depends on pixel format
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5222 static int rlGetPixelDataSize(int width, int height, int format)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5223 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5224 int dataSize = 0; // Size in bytes
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5225 int bpp = 0; // Bits per pixel
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5226
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5227 switch (format)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5228 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5229 case RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE: bpp = 8; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5230 case RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5231 case RL_PIXELFORMAT_UNCOMPRESSED_R5G6B5:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5232 case RL_PIXELFORMAT_UNCOMPRESSED_R5G5B5A1:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5233 case RL_PIXELFORMAT_UNCOMPRESSED_R4G4B4A4: bpp = 16; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5234 case RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: bpp = 32; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5235 case RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8: bpp = 24; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5236 case RL_PIXELFORMAT_UNCOMPRESSED_R32: bpp = 32; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5237 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32: bpp = 32*3; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5238 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: bpp = 32*4; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5239 case RL_PIXELFORMAT_UNCOMPRESSED_R16: bpp = 16; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5240 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: bpp = 16*3; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5241 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: bpp = 16*4; break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5242 case RL_PIXELFORMAT_COMPRESSED_DXT1_RGB:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5243 case RL_PIXELFORMAT_COMPRESSED_DXT1_RGBA:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5244 case RL_PIXELFORMAT_COMPRESSED_ETC1_RGB:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5245 case RL_PIXELFORMAT_COMPRESSED_ETC2_RGB:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5246 case RL_PIXELFORMAT_COMPRESSED_PVRT_RGB:
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5247 case RL_PIXELFORMAT_COMPRESSED_PVRT_RGBA: // 8 bytes per each 4x4 block
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5248 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5249 int blockWidth = (width + 3)/4;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5250 int blockHeight = (height + 3)/4;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5251 dataSize = blockWidth*blockHeight*8;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5252 } break;
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5253 case RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5254 case RL_PIXELFORMAT_COMPRESSED_DXT5_RGBA:
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5255 case RL_PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA:
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5256 case RL_PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA: // 16 bytes per each 4x4 block
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5257 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5258 int blockWidth = (width + 3)/4;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5259 int blockHeight = (height + 3)/4;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5260 dataSize = blockWidth*blockHeight*16;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5261 } break;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5262 case RL_PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA: // 4 bytes per each 4x4 block
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5263 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5264 int blockWidth = (width + 3)/4;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5265 int blockHeight = (height + 3)/4;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5266 dataSize = blockWidth*blockHeight*4;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5267 } break;
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5268 default: break;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5269 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5270
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5271 // Compute dataSize for uncompressed texture data (no blocks)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5272 if ((format >= RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) &&
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5273 (format <= RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16))
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5274 {
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5275 double bytesPerPixel = (double)bpp/8.0;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5276 dataSize = (int)(bytesPerPixel*width*height); // Total data size in bytes
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5277 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5278
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5279 return dataSize;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5280 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5281
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5282 // Auxiliar math functions
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5283 //-------------------------------------------------------------------------------
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5284 // Get identity matrix
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5285 static Matrix rlMatrixIdentity(void)
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5286 {
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5287 Matrix matIdentity = { 0 };
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5288 matIdentity.m0 = 1.0f;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5289 matIdentity.m5 = 1.0f;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5290 matIdentity.m10 = 1.0f;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5291 matIdentity.m15 = 1.0f;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5292
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5293 return matIdentity;
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5294 }
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5295 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5296 // Get float array of matrix data
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5297 // Explicit conversion to column-major memory layout
11
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5298 static rl_float16 rlMatrixToFloatV(Matrix mat)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5299 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5300 rl_float16 result = { 0 };
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5301
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5302 result.v[0] = mat.m0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5303 result.v[1] = mat.m1;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5304 result.v[2] = mat.m2;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5305 result.v[3] = mat.m3;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5306 result.v[4] = mat.m4;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5307 result.v[5] = mat.m5;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5308 result.v[6] = mat.m6;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5309 result.v[7] = mat.m7;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5310 result.v[8] = mat.m8;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5311 result.v[9] = mat.m9;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5312 result.v[10] = mat.m10;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5313 result.v[11] = mat.m11;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5314 result.v[12] = mat.m12;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5315 result.v[13] = mat.m13;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5316 result.v[14] = mat.m14;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5317 result.v[15] = mat.m15;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5318
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5319 return result;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5320 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5321
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5322 // Get two matrix multiplication
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5323 // NOTE: When multiplying matrices... the order matters!
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5324 static Matrix rlMatrixMultiply(Matrix left, Matrix right)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5325 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5326 Matrix result = { 0 };
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5327
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5328 result.m0 = left.m0*right.m0 + left.m1*right.m4 + left.m2*right.m8 + left.m3*right.m12;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5329 result.m1 = left.m0*right.m1 + left.m1*right.m5 + left.m2*right.m9 + left.m3*right.m13;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5330 result.m2 = left.m0*right.m2 + left.m1*right.m6 + left.m2*right.m10 + left.m3*right.m14;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5331 result.m3 = left.m0*right.m3 + left.m1*right.m7 + left.m2*right.m11 + left.m3*right.m15;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5332 result.m4 = left.m4*right.m0 + left.m5*right.m4 + left.m6*right.m8 + left.m7*right.m12;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5333 result.m5 = left.m4*right.m1 + left.m5*right.m5 + left.m6*right.m9 + left.m7*right.m13;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5334 result.m6 = left.m4*right.m2 + left.m5*right.m6 + left.m6*right.m10 + left.m7*right.m14;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5335 result.m7 = left.m4*right.m3 + left.m5*right.m7 + left.m6*right.m11 + left.m7*right.m15;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5336 result.m8 = left.m8*right.m0 + left.m9*right.m4 + left.m10*right.m8 + left.m11*right.m12;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5337 result.m9 = left.m8*right.m1 + left.m9*right.m5 + left.m10*right.m9 + left.m11*right.m13;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5338 result.m10 = left.m8*right.m2 + left.m9*right.m6 + left.m10*right.m10 + left.m11*right.m14;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5339 result.m11 = left.m8*right.m3 + left.m9*right.m7 + left.m10*right.m11 + left.m11*right.m15;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5340 result.m12 = left.m12*right.m0 + left.m13*right.m4 + left.m14*right.m8 + left.m15*right.m12;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5341 result.m13 = left.m12*right.m1 + left.m13*right.m5 + left.m14*right.m9 + left.m15*right.m13;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5342 result.m14 = left.m12*right.m2 + left.m13*right.m6 + left.m14*right.m10 + left.m15*right.m14;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5343 result.m15 = left.m12*right.m3 + left.m13*right.m7 + left.m14*right.m11 + left.m15*right.m15;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5344
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5345 return result;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5346 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5347
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5348 // Transposes provided matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5349 static Matrix rlMatrixTranspose(Matrix mat)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5350 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5351 Matrix result = { 0 };
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5352
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5353 result.m0 = mat.m0;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5354 result.m1 = mat.m4;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5355 result.m2 = mat.m8;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5356 result.m3 = mat.m12;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5357 result.m4 = mat.m1;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5358 result.m5 = mat.m5;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5359 result.m6 = mat.m9;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5360 result.m7 = mat.m13;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5361 result.m8 = mat.m2;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5362 result.m9 = mat.m6;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5363 result.m10 = mat.m10;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5364 result.m11 = mat.m14;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5365 result.m12 = mat.m3;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5366 result.m13 = mat.m7;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5367 result.m14 = mat.m11;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5368 result.m15 = mat.m15;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5369
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5370 return result;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5371 }
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5372
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5373 // Invert provided matrix
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5374 static Matrix rlMatrixInvert(Matrix mat)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5375 {
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5376 Matrix result = { 0 };
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5377
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5378 // Cache the matrix values (speed optimization)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5379 float a00 = mat.m0, a01 = mat.m1, a02 = mat.m2, a03 = mat.m3;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5380 float a10 = mat.m4, a11 = mat.m5, a12 = mat.m6, a13 = mat.m7;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5381 float a20 = mat.m8, a21 = mat.m9, a22 = mat.m10, a23 = mat.m11;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5382 float a30 = mat.m12, a31 = mat.m13, a32 = mat.m14, a33 = mat.m15;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5383
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5384 float b00 = a00*a11 - a01*a10;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5385 float b01 = a00*a12 - a02*a10;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5386 float b02 = a00*a13 - a03*a10;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5387 float b03 = a01*a12 - a02*a11;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5388 float b04 = a01*a13 - a03*a11;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5389 float b05 = a02*a13 - a03*a12;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5390 float b06 = a20*a31 - a21*a30;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5391 float b07 = a20*a32 - a22*a30;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5392 float b08 = a20*a33 - a23*a30;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5393 float b09 = a21*a32 - a22*a31;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5394 float b10 = a21*a33 - a23*a31;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5395 float b11 = a22*a33 - a23*a32;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5396
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5397 // Calculate the invert determinant (inlined to avoid double-caching)
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5398 float invDet = 1.0f/(b00*b11 - b01*b10 + b02*b09 + b03*b08 - b04*b07 + b05*b06);
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5399
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5400 result.m0 = (a11*b11 - a12*b10 + a13*b09)*invDet;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5401 result.m1 = (-a01*b11 + a02*b10 - a03*b09)*invDet;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5402 result.m2 = (a31*b05 - a32*b04 + a33*b03)*invDet;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5403 result.m3 = (-a21*b05 + a22*b04 - a23*b03)*invDet;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5404 result.m4 = (-a10*b11 + a12*b08 - a13*b07)*invDet;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5405 result.m5 = (a00*b11 - a02*b08 + a03*b07)*invDet;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5406 result.m6 = (-a30*b05 + a32*b02 - a33*b01)*invDet;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5407 result.m7 = (a20*b05 - a22*b02 + a23*b01)*invDet;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5408 result.m8 = (a10*b10 - a11*b08 + a13*b06)*invDet;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5409 result.m9 = (-a00*b10 + a01*b08 - a03*b06)*invDet;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5410 result.m10 = (a30*b04 - a31*b02 + a33*b00)*invDet;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5411 result.m11 = (-a20*b04 + a21*b02 - a23*b00)*invDet;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5412 result.m12 = (-a10*b09 + a11*b07 - a12*b06)*invDet;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5413 result.m13 = (a00*b09 - a01*b07 + a02*b06)*invDet;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5414 result.m14 = (-a30*b03 + a31*b01 - a32*b00)*invDet;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5415 result.m15 = (a20*b03 - a21*b01 + a22*b00)*invDet;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5416
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5417 return result;
f33d9ff8b6e8 [Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5418 }
276
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5419 #endif
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5420
b55c22cff335 Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents: 11
diff changeset
5421 #endif // RLGL_IMPLEMENTATION