void GL2Encoder::s_glUseProgram(void *self, GLuint program) { GL2Encoder *ctx = (GL2Encoder*)self; GLClientState* state = ctx->m_state; GLSharedGroupPtr shared = ctx->m_shared; ctx->m_glUseProgram_enc(self, program); ctx->m_state->setCurrentProgram(program); GLenum origActiveTexture = state->getActiveTextureUnit(); GLenum hostActiveTexture = origActiveTexture; GLint samplerIdx = -1; GLint samplerVal; GLenum samplerTarget; while ((samplerIdx = shared->getNextSamplerUniform(program, samplerIdx, &samplerVal, &samplerTarget)) != -1) { if (samplerVal < 0 || samplerVal >= GLClientState::MAX_TEXTURE_UNITS) continue; if (ctx->updateHostTexture2DBinding(GL_TEXTURE0 + samplerVal, samplerTarget)) { hostActiveTexture = GL_TEXTURE0 + samplerVal; } } state->setActiveTextureUnit(origActiveTexture); if (hostActiveTexture != origActiveTexture) { ctx->m_glActiveTexture_enc(self, origActiveTexture); } }
void GL2Encoder::s_glUniform1i(void *self , GLint location, GLint x) { GL2Encoder *ctx = (GL2Encoder*)self; GLClientState* state = ctx->m_state; GLSharedGroupPtr shared = ctx->m_shared; GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location); ctx->m_glUniform1i_enc(self, hostLoc, x); GLenum target; if (shared->setSamplerUniform(state->currentProgram(), location, x, &target)) { GLenum origActiveTexture = state->getActiveTextureUnit(); if (ctx->updateHostTexture2DBinding(GL_TEXTURE0 + x, target)) { ctx->m_glActiveTexture_enc(self, origActiveTexture); } state->setActiveTextureUnit(origActiveTexture); } }