MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / switchEffectConfig

Method switchEffectConfig

source/application/StarRenderer_opengl.cpp:470–517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

468}
469
470bool OpenGlRenderer::switchEffectConfig(String const& name) {
471 flushImmediatePrimitives();
472 auto find = m_effects.find(name);
473 if (find == m_effects.end())
474 return false;
475
476 Effect& effect = find->second;
477 if (m_currentEffect == &effect)
478 return true;
479
480 if (auto blitFrameBufferId = effect.config.optString("blitFrameBuffer"))
481 blitGlFrameBuffer(getGlFrameBuffer(*blitFrameBufferId));
482
483 auto effectScreenSize = m_screenSize;
484 if (auto frameBufferId = effect.config.optString("frameBuffer")) {
485 auto buf = getGlFrameBuffer(*frameBufferId);
486 switchGlFrameBuffer(buf);
487 effectScreenSize = m_screenSize / (buf->sizeDiv);
488 } else {
489 m_currentFrameBuffer.reset();
490 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
491 }
492
493 glUseProgram(m_program = effect.program);
494 setupGlUniforms(effect, effectScreenSize);
495 m_currentEffect = &effect;
496
497 setEffectParameter("vertexRounding", m_multiSampling > 0);
498 if (auto fbts = effect.config.optArray("frameBufferTextures")) {
499 for (auto const& fbt : *fbts) {
500 if (auto frameBufferId = fbt.optString("framebuffer")) {
501 auto textureUniform = fbt.getString("texture");
502 auto ptr = m_currentEffect->textures.ptr(textureUniform);
503 if (ptr) {
504 if (!ptr->textureValue || ptr->textureValue->textureId == 0) {
505 auto texture = getGlFrameBuffer(*frameBufferId)->texture;
506 ptr->textureValue = texture;
507 if (ptr->textureSizeUniform != -1) {
508 auto textureSize = ptr->textureValue->glTextureSize();
509 glUniform2f(ptr->textureSizeUniform, textureSize[0], textureSize[1]);
510 }
511 }
512 }
513 }
514 }
515 }
516 return true;
517}
518
519void OpenGlRenderer::setScissorRect(Maybe<RectI> const& scissorRect) {
520 if (scissorRect == m_scissorRect)

Callers 1

renderMethod · 0.80

Calls 8

optStringMethod · 0.80
optArrayMethod · 0.80
getStringMethod · 0.80
glTextureSizeMethod · 0.80
findMethod · 0.45
endMethod · 0.45
resetMethod · 0.45
ptrMethod · 0.45

Tested by

no test coverage detected