MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / Init

Method Init

Engine/source/environment/VolumetricFogRTManager.cpp:131–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131bool VolumetricFogRTManager::Init()
132{
133 if (mIsInitialized)
134 {
135 Con::errorf("VolumetricFogRTManager allready initialized!!");
136 return true;
137 }
138
139 if (GFX->getAdapterType() == NullDevice)
140 {
141 mIsInitialized = true;
142 Con::errorf("VolumetricFogRTManager - Dedicated server");
143 return true;
144 }
145
146 GuiCanvas* cv = dynamic_cast<GuiCanvas*>(Sim::findObject("Canvas"));
147 if (cv == NULL)
148 {
149 Con::errorf("VolumetricFogRTManager::Init() - Canvas not found!!");
150 return false;
151 }
152
153 mPlatformWindow = cv->getPlatformWindow();
154 mPlatformWindow->resizeEvent.notify(this,&VolumetricFogRTManager::ResizeRT);
155
156 if (mTargetScale < 1 || GFX->getAdapterType() == Direct3D11)
157 mTargetScale = 1;
158
159 mWidth = mFloor(mPlatformWindow->getClientExtent().x / mTargetScale);
160 mHeight = mFloor(mPlatformWindow->getClientExtent().y / mTargetScale);
161
162 mDepthBuffer = GFXTexHandle(mWidth, mHeight, GFXFormatR32F,
163 &GFXRenderTargetProfile, avar("%s() - mDepthBuffer (line %d)", __FUNCTION__, __LINE__));
164 if (!mDepthBuffer.isValid())
165 {
166 Con::errorf("VolumetricFogRTManager Fatal Error: Unable to create Depthbuffer");
167 return false;
168 }
169 if (!mDepthTarget.registerWithName("volfogdepth"))
170 {
171 Con::errorf("VolumetricFogRTManager Fatal Error : Unable to register Depthbuffer");
172 return false;
173 }
174 mDepthTarget.setTexture(mDepthBuffer);
175
176 mFrontBuffer = GFXTexHandle(mWidth, mHeight, GFXFormatR32F,
177 &GFXRenderTargetProfile, avar("%s() - mFrontBuffer (line %d)", __FUNCTION__, __LINE__));
178 if (!mFrontBuffer.isValid())
179 {
180 Con::errorf("VolumetricFogRTManager Fatal Error: Unable to create front buffer");
181 return false;
182 }
183 if (!mFrontTarget.registerWithName("volfogfront"))
184 {
185 Con::errorf("VolumetricFogRTManager Fatal Error : Unable to register Frontbuffer");
186 return false;
187 }
188

Callers 1

VolumetricFogMethod · 0.45

Calls 13

mFloorFunction · 0.85
avarFunction · 0.85
setVariableFunction · 0.85
getPlatformWindowMethod · 0.80
registerWithNameMethod · 0.80
errorfFunction · 0.50
findObjectFunction · 0.50
GFXTexHandleClass · 0.50
getAdapterTypeMethod · 0.45
notifyMethod · 0.45
getClientExtentMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected