MCPcopy Create free account
hub / github.com/ZDoom/Raze / RenderViewpoint

Function RenderViewpoint

source/core/rendering/hw_entrypoint.cpp:111–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109//-----------------------------------------------------------------------------
110
111void RenderViewpoint(FRenderViewpoint& mainvp, IntRect* bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen)
112{
113 auto& RenderState = *screen->RenderState();
114
115 /*
116 if (mainview && toscreen)
117 {
118 screen->SetAABBTree(camera->Level->aabbTree);
119 screen->mShadowMap.SetCollectLights([=] {
120 CollectLights(camera->Level);
121 });
122 screen->UpdateShadowMap();
123 }
124 */
125
126 // Render (potentially) multiple views for stereo 3d
127 // Fixme. The view offsetting should be done with a static table and not require setup of the entire render state for the mode.
128 auto vrmode = VRMode::GetVRMode(mainview && toscreen);
129 const int eyeCount = vrmode->mEyeCount;
130 screen->FirstEye();
131 hw_int_useindexedcolortextures = eyeCount > 1? false : *hw_useindexedcolortextures;
132
133 for (int eye_ix = 0; eye_ix < eyeCount; ++eye_ix)
134 {
135 const auto& eye = vrmode->mEyes[eye_ix];
136 screen->SetViewportRects(bounds);
137
138 if (mainview) // Bind the scene frame buffer and turn on draw buffers used by ssao
139 {
140 bool useSSAO = (gl_ssao != 0);
141 screen->SetSceneRenderTarget(useSSAO);
142 RenderState.SetPassType(useSSAO ? GBUFFER_PASS : NORMAL_PASS);
143 RenderState.EnableDrawBuffers(RenderState.GetPassDrawBufferCount(), true);
144 }
145
146 auto di = HWDrawInfo::StartDrawInfo(nullptr, mainvp, nullptr);
147 di->SetVisibility();
148 auto& vp = di->Viewpoint;
149 vp = mainvp;
150
151 di->Set3DViewport(RenderState);
152 float flash = 8.f / (r_scenebrightness + 8.f);
153 di->Viewpoint.FieldOfView = FAngle::fromDeg(fov); // Set the real FOV for the current scene (it's not necessarily the same as the global setting in r_viewpoint)
154
155 // Stereo mode specific perspective projection
156 di->VPUniforms.mProjectionMatrix = eye.GetProjection(fov, ratio, fovratio, false);
157
158 // Stereo mode specific viewpoint adjustment
159 if (eye.mShiftFactor != 0)
160 {
161 vp.Pos += eye.GetViewShift(vp.HWAngles.Yaw.Degrees());
162 sectortype* sect = &sector[vp.SectCount];
163 updatesector(DVector2(vp.Pos.X, -vp.Pos.Y), &sect);
164 vp.SectCount = sectindex(sect);
165 }
166
167 di->SetupView(RenderState, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, false, false);
168 di->ProcessScene(toscreen);

Callers 3

RenderToSavePicFunction · 0.85
render_drawroomsFunction · 0.85
render_camtexFunction · 0.85

Calls 15

updatesectorFunction · 0.85
sectindexFunction · 0.85
Draw2DFunction · 0.85
SetPassTypeMethod · 0.80
SetVisibilityMethod · 0.80
Set3DViewportMethod · 0.80
GetProjectionMethod · 0.80
GetViewShiftMethod · 0.80
DegreesMethod · 0.80
SetupViewMethod · 0.80
ProcessSceneMethod · 0.80

Tested by

no test coverage detected