From 47c6270ece58dfe262c1f8f1fefc0a94d1664e09 Mon Sep 17 00:00:00 2001 From: Ivan Epifanov Date: Wed, 9 Dec 2020 15:28:57 +0300 Subject: [PATCH] Fix a bug in vitagles2 renderer --- src/render/vitagles2/SDL_render_gles2vita.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/render/vitagles2/SDL_render_gles2vita.c b/src/render/vitagles2/SDL_render_gles2vita.c index f74db3abb..97a23ce16 100644 --- a/src/render/vitagles2/SDL_render_gles2vita.c +++ b/src/render/vitagles2/SDL_render_gles2vita.c @@ -1202,12 +1202,16 @@ VITA_GLES2_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void } /* upload the new VBO data for this set of commands. */ - data->glBindBuffer(GL_ARRAY_BUFFER, vbo); - if (data->vertex_buffer_size[vboidx] < vertsize) { - data->glBufferData(GL_ARRAY_BUFFER, vertsize, vertices, GL_DYNAMIC_DRAW); - data->vertex_buffer_size[vboidx] = vertsize; - } else { - data->glBufferSubData(GL_ARRAY_BUFFER, 0, vertsize, vertices); + /* NULL/zero vertices could happen SetRenderTarget is the first render command */ + if (vertsize > 0 && vertices != NULL) + { + data->glBindBuffer(GL_ARRAY_BUFFER, vbo); + if (data->vertex_buffer_size[vboidx] < vertsize) { + data->glBufferData(GL_ARRAY_BUFFER, vertsize, vertices, GL_DYNAMIC_DRAW); + data->vertex_buffer_size[vboidx] = vertsize; + } else { + data->glBufferSubData(GL_ARRAY_BUFFER, 0, vertsize, vertices); + } } /* cycle through a few VBOs so the GL has some time with the data before we replace it. */