Use 16 bit indices on phones that dont support 32, fixes #19797
This commit is contained in:
parent
0c54e6344b
commit
682fdf0f74
3 changed files with 20 additions and 3 deletions
|
@ -317,9 +317,17 @@ void RasterizerCanvasGLES2::_draw_polygon(const int *p_indices, int p_index_coun
|
|||
}
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer);
|
||||
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(int) * p_index_count, p_indices);
|
||||
|
||||
glDrawElements(GL_TRIANGLES, p_index_count, GL_UNSIGNED_INT, 0);
|
||||
if (storage->config.support_32_bits_indices) { //should check for
|
||||
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(int) * p_index_count, p_indices);
|
||||
glDrawElements(GL_TRIANGLES, p_index_count, GL_UNSIGNED_INT, 0);
|
||||
} else {
|
||||
uint16_t *index16 = (uint16_t *)alloca(sizeof(uint16_t) * p_index_count);
|
||||
for (int i = 0; i < p_index_count; i++) {
|
||||
index16[i] = uint16_t(p_indices[i]);
|
||||
}
|
||||
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(uint16_t) * p_index_count, index16);
|
||||
glDrawElements(GL_TRIANGLES, p_index_count, GL_UNSIGNED_SHORT, 0);
|
||||
}
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
|
|
|
@ -4658,6 +4658,13 @@ void RasterizerStorageGLES2::initialize() {
|
|||
#else
|
||||
config.use_rgba_2d_shadows = !(config.float_texture_supported && config.extensions.has("GL_EXT_texture_rg"));
|
||||
#endif
|
||||
|
||||
#ifdef GLES_OVER_GL
|
||||
config.support_32_bits_indices = true;
|
||||
#else
|
||||
config.support_32_bits_indices = config.extensions.has("GL_OES_element_index_uint");
|
||||
#endif
|
||||
|
||||
frame.count = 0;
|
||||
frame.delta = 0;
|
||||
frame.current_rt = NULL;
|
||||
|
|
|
@ -78,6 +78,8 @@ public:
|
|||
bool force_vertex_shading;
|
||||
|
||||
bool use_rgba_2d_shadows;
|
||||
|
||||
bool support_32_bits_indices;
|
||||
} config;
|
||||
|
||||
struct Resources {
|
||||
|
|
Loading…
Reference in a new issue