gles: only use GLES3 functions on android

This commit is contained in:
Flyinghead 2019-04-04 08:10:32 +00:00
parent eadf3047c0
commit 125cccaa5a
3 changed files with 22 additions and 4 deletions

View File

@ -934,9 +934,10 @@ void SetMVS_Mode(ModifierVolumeMode mv_mode, ISP_Modvol ispc)
static void SetupMainVBO()
{
#if !defined(GLES) || defined(_ANDROID)
if (gl.gl_major >= 3)
glBindVertexArray(gl.vbo.vao);
#endif
glBindBuffer(GL_ARRAY_BUFFER, gl.vbo.geometry); glCheck();
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gl.vbo.idxs); glCheck();
@ -956,9 +957,10 @@ static void SetupMainVBO()
void SetupModvolVBO()
{
#if !defined(GLES) || defined(_ANDROID)
if (gl.gl_major >= 3)
glBindVertexArray(gl.vbo.vao);
#endif
glBindBuffer(GL_ARRAY_BUFFER, gl.vbo.modvols); glCheck();
//setup vertex buffers attrib pointers

View File

@ -1150,7 +1150,9 @@ bool gl_create_resources()
//create vao
//This is really not "proper", vaos are supposed to be defined once
//i keep updating the same one to make the es2 code work in 3.1 context
#if !defined(GLES) || defined(_ANDROID)
glGenVertexArrays(1, &gl.vbo.vao);
#endif
}
//create vbos
@ -1991,8 +1993,10 @@ struct glesrend : Renderer
void DrawOSD(bool clear_screen)
{
#if !defined(GLES) || defined(_ANDROID)
if (gl.gl_major >= 3)
glBindVertexArray(gl.vbo.vao);
#endif
glBindBuffer(GL_ARRAY_BUFFER, gl.vbo.geometry); glCheck();
glEnableVertexAttribArray(VERTEX_POS_ARRAY);
glVertexAttribPointer(VERTEX_POS_ARRAY, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex,x));

View File

@ -161,6 +161,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data, bool save_backgr
if (save_background)
{
#if !defined(GLES) || defined(_ANDROID)
if (!gl.is_gles && glReadBuffer != NULL)
glReadBuffer(GL_FRONT);
@ -177,6 +178,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data, bool save_backgr
// Copy the current framebuffer into it
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, fb_width, fb_height);
#endif
}
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
@ -208,10 +210,12 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data, bool save_backgr
glUseProgram(g_ShaderHandle);
glUniform1i(g_AttribLocationTex, 0);
glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
#if !defined(GLES) || defined(_ANDROID)
if (gl.gl_major >= 3 && glBindSampler != NULL)
glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.
#endif
GLuint vao_handle = 0;
#if !defined(GLES) || defined(_ANDROID)
if (gl.gl_major >= 3)
{
// Recreate the VAO every time
@ -219,6 +223,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data, bool save_backgr
glGenVertexArrays(1, &vao_handle);
glBindVertexArray(vao_handle);
}
#endif
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
glEnableVertexAttribArray(g_AttribLocationPosition);
glEnableVertexAttribArray(g_AttribLocationUV);
@ -267,18 +272,23 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data, bool save_backgr
idx_buffer_offset += pcmd->ElemCount;
}
}
#if !defined(GLES) || defined(_ANDROID)
if (vao_handle != 0)
glDeleteVertexArrays(1, &vao_handle);
#endif
// Restore modified GL state
glUseProgram(last_program);
glBindTexture(GL_TEXTURE_2D, last_texture);
#if !defined(GLES) || defined(_ANDROID)
if (gl.gl_major >= 3 && glBindSampler != NULL)
glBindSampler(0, last_sampler);
#endif
glActiveTexture(last_active_texture);
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
#if !defined(GLES) || defined(_ANDROID)
if (gl.gl_major >= 3)
glBindVertexArray(last_vertex_array);
#endif
glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha);
glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha);
if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND);
@ -537,8 +547,10 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects()
// Restore modified GL state
glBindTexture(GL_TEXTURE_2D, last_texture);
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
#if !defined(GLES) || defined(_ANDROID)
if (gl.gl_major >= 3)
glBindVertexArray(last_vertex_array);
#endif
return true;
}