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

Method BuildFrameState

engine/PoseidonGL33/EngineGL33_Shaders.cpp:891–942  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

889}
890
891FrameState EngineGL33::BuildFrameState(Camera* camera, LightSun* sun, int bias, const Color& fogColor, bool sunEnabled)
892{
893 FrameState frame = {};
894
895 ConvertMatrix(frame.view, camera->InverseScaled());
896 frame.view._41 = 0;
897 frame.view._42 = 0;
898 frame.view._43 = 0;
899
900 int projBias = _canZBias ? 0 : bias;
901 ConvertProjectionMatrix(frame.projection, camera->ProjectionNormal(), projBias);
902
903 Vector3 pos = camera->Position();
904 frame.cameraPos[0] = static_cast<float>(pos.X());
905 frame.cameraPos[1] = static_cast<float>(pos.Y());
906 frame.cameraPos[2] = static_cast<float>(pos.Z());
907
908 frame.viewport[0] = 0;
909 frame.viewport[1] = 0;
910 frame.viewport[2] = static_cast<float>(_w);
911 frame.viewport[3] = static_cast<float>(_h);
912
913 // Fog parameters — use the scene's actual fog range (driven by weather /
914 // rain / clamp), matching what D3D8 set D3DRS_FOGSTART/END from and the
915 // per-vertex Fog8/SkyFog8 tables.
916 float wFogStart = camera->ClipNear();
917 float wFogEnd = camera->ClipFar();
918 if (GScene)
919 {
920 wFogStart = GScene->GetFogMinRange();
921 wFogEnd = GScene->GetFogMaxRange();
922 }
923 float fogInvRange = (wFogEnd > wFogStart) ? 1.0f / (wFogEnd - wFogStart) : 0.0f;
924 frame.fogParams[0] = wFogStart;
925 frame.fogParams[1] = fogInvRange;
926 frame.fogParams[2] = 1.0f; // enabled
927 frame.fogParams[3] = 0;
928
929 frame.fogColor[0] = fogColor.R();
930 frame.fogColor[1] = fogColor.G();
931 frame.fogColor[2] = fogColor.B();
932 frame.fogColor[3] = 1.0f;
933
934 Vector3 dir = sun->Direction();
935 frame.sunDir[0] = dir.X();
936 frame.sunDir[1] = dir.Y();
937 frame.sunDir[2] = dir.Z();
938 frame.sunDir[3] = 0;
939 frame.sunEnabled = sunEnabled;
940
941 return frame;
942}
943
944PassState EngineGL33::BuildPassState(const FrameState& frame, PassId passId)
945{

Callers

nothing calls this directly

Calls 15

ConvertMatrixFunction · 0.85
ConvertProjectionMatrixFunction · 0.85
ClipNearMethod · 0.80
ClipFarMethod · 0.80
GetFogMinRangeMethod · 0.80
GetFogMaxRangeMethod · 0.80
InverseScaledMethod · 0.45
PositionMethod · 0.45
XMethod · 0.45
YMethod · 0.45
ZMethod · 0.45
RMethod · 0.45

Tested by

no test coverage detected