summaryrefslogtreecommitdiffhomepage
path: root/src/rlgl.h
diff options
context:
space:
mode:
authorRay <[email protected]>2019-04-05 16:43:09 +0200
committerRay <[email protected]>2019-04-05 16:43:09 +0200
commitc600dd07668f301fc1a986326d807f341e6ecb78 (patch)
tree436bd51bfb4a3d0ee4521451883ffe40fec92782 /src/rlgl.h
parent0f9fe34c3a9228eaa3ffdb3be3f52ba586d1ddfa (diff)
downloadraylib-c600dd07668f301fc1a986326d807f341e6ecb78.tar.gz
raylib-c600dd07668f301fc1a986326d807f341e6ecb78.zip
Review PBR shaders
Issue was related to vertex tangent attibutes not uploaded to GPU, a quick solution was implemented for new vertex attributes loading for already existing meshes... I don't like it specially but it will work for now.
Diffstat (limited to 'src/rlgl.h')
-rw-r--r--src/rlgl.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/rlgl.h b/src/rlgl.h
index 3d433377..bf50ad0d 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -456,6 +456,7 @@ void rlDeleteBuffers(unsigned int id); // Unload vertex data (V
void rlClearColor(byte r, byte g, byte b, byte a); // Clear color buffer with color
void rlClearScreenBuffers(void); // Clear used screen buffers (color and depth)
void rlUpdateBuffer(int bufferId, void *data, int dataSize); // Update GPU buffer with new data
+unsigned int rlLoadAttribBuffer(unsigned int vaoId, int shaderLoc, void *buffer, int size, bool dynamic); // Load a new attributes buffer
//------------------------------------------------------------------------------------
// Functions Declaration - rlgl functionality
@@ -2532,6 +2533,29 @@ void rlLoadMesh(Mesh *mesh, bool dynamic)
#endif
}
+// Load a new attributes buffer
+unsigned int rlLoadAttribBuffer(unsigned int vaoId, int shaderLoc, void *buffer, int size, bool dynamic)
+{
+ unsigned int id = 0;
+
+#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
+ int drawHint = GL_STATIC_DRAW;
+ if (dynamic) drawHint = GL_DYNAMIC_DRAW;
+
+ if (vaoSupported) glBindVertexArray(vaoId);
+
+ glGenBuffers(1, &id);
+ glBindBuffer(GL_ARRAY_BUFFER, id);
+ glBufferData(GL_ARRAY_BUFFER, size, buffer, drawHint);
+ glVertexAttribPointer(shaderLoc, 2, GL_FLOAT, 0, 0, 0);
+ glEnableVertexAttribArray(shaderLoc);
+
+ if (vaoSupported) glBindVertexArray(0);
+#endif
+
+ return id;
+}
+
// Update vertex data on GPU (upload new data to one buffer)
void rlUpdateMesh(Mesh mesh, int buffer, int numVertex)
{