MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / SetMultiTexturing

Method SetMultiTexturing

engine/PoseidonGL33/EngineGL33_State.cpp:678–729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

676}
677
678void EngineGL33::SetMultiTexturing(VFormatSet format)
679{
680 if (_formatSet == format)
681 return;
682 _formatSet = format;
683
684 // Same FF-equivalence rationale as SetTexture: a SingleTex shader still
685 // has sampler1 declared; even if it doesn't sample (or its result is
686 // multiplied out), the driver validates the binding. Bind the white
687 // sentinel for SingleTex / for any null detail-spec-grass texture.
688 unsigned int boundHandle = _fallbackWhiteTex;
689 switch (format)
690 {
691 case SingleTex:
692 boundHandle = _fallbackWhiteTex;
693 break;
694 case DetailTex:
695 {
696 TextureGL33* detail = _textBank ? _textBank->GetDetailTexture() : nullptr;
697 if (_textBank && detail)
698 _textBank->UseMipmap(detail, 0, 0);
699 unsigned int dh = detail ? detail->GetHandle() : 0;
700 LOG_DEBUG(Graphics, "GL33: SetMultiTex DetailTex handle={} detail={}", dh, (void*)detail);
701 boundHandle = dh ? dh : _fallbackWhiteTex;
702 break;
703 }
704 case GrassTex:
705 {
706 TextureGL33* grass = _textBank ? _textBank->GetGrassTexture() : nullptr;
707 if (_textBank && grass)
708 _textBank->UseMipmap(grass, 0, 0);
709 unsigned int gh = grass ? grass->GetHandle() : 0;
710 boundHandle = gh ? gh : _fallbackWhiteTex;
711 break;
712 }
713 case SpecularTex:
714 {
715 TextureGL33* spec = _textBank ? _textBank->GetSpecularTexture() : nullptr;
716 if (_textBank && spec)
717 _textBank->UseMipmap(spec, 0, 0);
718 unsigned int sh = spec ? spec->GetHandle() : 0;
719 boundHandle = sh ? sh : _fallbackWhiteTex;
720 break;
721 }
722 }
723 GL33Bind::Tex2D(1, boundHandle);
724 GL33Bind::ActiveUnit(0);
725 // Snapshot for the frame capture: latch the resolved handle so the next TL
726 // capture knows what's bound on TEXTURE1, even across the
727 // early-out path above.
728 _lastTexture1Handle = boundHandle;
729}

Callers

nothing calls this directly

Calls 7

Tex2DFunction · 0.85
ActiveUnitFunction · 0.85
GetDetailTextureMethod · 0.80
GetHandleMethod · 0.80
GetGrassTextureMethod · 0.80
GetSpecularTextureMethod · 0.80
UseMipmapMethod · 0.45

Tested by

no test coverage detected