summaryrefslogtreecommitdiff
path: root/drivers/gles3/storage
diff options
context:
space:
mode:
authorclayjohn <claynjohn@gmail.com>2022-05-25 13:19:45 -0700
committerclayjohn <claynjohn@gmail.com>2022-05-25 15:46:24 -0700
commitfb860265e0f0c93166f87fecb4c0fb4a7965d45d (patch)
treeefeebb12293f6a5f08f9f9823e03bd1cc5a66e56 /drivers/gles3/storage
parent3e20c1347db323438a76693bb9f7eea87f3a305d (diff)
Implement 2D Meshes and MultiMeshes in GLES3 backend
Diffstat (limited to 'drivers/gles3/storage')
-rw-r--r--drivers/gles3/storage/mesh_storage.cpp13
-rw-r--r--drivers/gles3/storage/mesh_storage.h20
2 files changed, 32 insertions, 1 deletions
diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp
index 3be1792868..822be25337 100644
--- a/drivers/gles3/storage/mesh_storage.cpp
+++ b/drivers/gles3/storage/mesh_storage.cpp
@@ -722,6 +722,18 @@ void MeshStorage::_mesh_surface_generate_version_for_input_mask(Mesh::Surface::V
for (int i = 0; i < RS::ARRAY_INDEX; i++) {
if (!attribs[i].enabled) {
+ glDisableVertexAttribArray(i);
+ if (s->format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
+ if (i == RS::ARRAY_COLOR) {
+ glVertexAttrib4f(i, 1, 1, 1, 1);
+ } else if (i == RS::ARRAY_TEX_UV) {
+ glVertexAttrib2f(i, 1, 1);
+ } else if (i == RS::ARRAY_BONES) {
+ glVertexAttrib4f(i, 1, 1, 1, 1);
+ } else if (i == RS::ARRAY_WEIGHTS) {
+ glVertexAttrib4f(i, 1, 1, 1, 1);
+ }
+ }
continue;
}
if (i <= RS::ARRAY_TANGENT) {
@@ -941,7 +953,6 @@ void MeshStorage::multimesh_allocate_data(RID p_multimesh, int p_instances, RS::
multimesh->stride_cache = multimesh->custom_data_offset_cache + (p_use_custom_data ? 4 : 0);
multimesh->buffer_set = false;
- //print_line("allocate, elements: " + itos(p_instances) + " 2D: " + itos(p_transform_format == RS::MULTIMESH_TRANSFORM_2D) + " colors " + itos(multimesh->uses_colors) + " data " + itos(multimesh->uses_custom_data) + " stride " + itos(multimesh->stride_cache) + " total size " + itos(multimesh->stride_cache * multimesh->instances));
multimesh->data_cache = Vector<float>();
multimesh->aabb = AABB();
multimesh->aabb_dirty = false;
diff --git a/drivers/gles3/storage/mesh_storage.h b/drivers/gles3/storage/mesh_storage.h
index 991777842f..068aa2fe40 100644
--- a/drivers/gles3/storage/mesh_storage.h
+++ b/drivers/gles3/storage/mesh_storage.h
@@ -493,6 +493,26 @@ public:
return multimesh->instances;
}
+ _FORCE_INLINE_ GLuint multimesh_get_gl_buffer(RID p_multimesh) const {
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
+ return multimesh->buffer;
+ }
+
+ _FORCE_INLINE_ uint32_t multimesh_get_stride(RID p_multimesh) const {
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
+ return multimesh->stride_cache;
+ }
+
+ _FORCE_INLINE_ uint32_t multimesh_get_color_offset(RID p_multimesh) const {
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
+ return multimesh->color_offset_cache;
+ }
+
+ _FORCE_INLINE_ uint32_t multimesh_get_custom_data_offset(RID p_multimesh) const {
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
+ return multimesh->custom_data_offset_cache;
+ }
+
/* SKELETON API */
Skeleton *get_skeleton(RID p_rid) { return skeleton_owner.get_or_null(p_rid); };