void ApplyTextures(GLState state, ref_ptr<GpuProgram> program) { ref_ptr<Texture> tex = state.GetColorTexture(); int8_t colorTexLoc = -1; if (tex != nullptr && (colorTexLoc = program->GetUniformLocation("u_colorTex")) >= 0) { GLFunctions::glActiveTexture(gl_const::GLTexture0); tex->Bind(); GLFunctions::glUniformValuei(colorTexLoc, 0); tex->SetFilter(state.GetTextureFilter()); } else { // Some Android devices (Galaxy Nexus) require to reset texture state explicitly. // It's caused by a bug in OpenGL driver (for Samsung Nexus, maybe others). Normally // we don't need to explicitly call glBindTexture(GL_TEXTURE2D, 0) after glUseProgram // in case of the GPU-program doesn't use textures. Here we have to do it to work around // graphics artefacts. The overhead isn't significant, we don't know on which devices // it may happen so do it for all Android devices. #ifdef OMIM_OS_ANDROID GLFunctions::glActiveTexture(gl_const::GLTexture0); GLFunctions::glBindTexture(0); #endif } tex = state.GetMaskTexture(); int8_t maskTexLoc = -1; if (tex != nullptr && (maskTexLoc = program->GetUniformLocation("u_maskTex")) >= 0) { GLFunctions::glActiveTexture(gl_const::GLTexture0 + 1); tex->Bind(); GLFunctions::glUniformValuei(maskTexLoc, 1); tex->SetFilter(state.GetTextureFilter()); } else { // Some Android devices (Galaxy Nexus) require to reset texture state explicitly. // See detailed description above. #ifdef OMIM_OS_ANDROID GLFunctions::glActiveTexture(gl_const::GLTexture0 + 1); GLFunctions::glBindTexture(0); #endif } }