Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 802 vs 804 for /trunk/Source Code/Rendering/DeferredShadingRenderer.cpp

Diff revisions: vs.
  @@ -3,9 +3,9 @@
3 3 #include "GUI/Headers/GUI.h"
4 4 #include "GUI/Headers/GUIText.h"
5 5 #include "Scenes/Headers/SceneState.h"
6 - #include "Core/Headers/Kernel.h"
7 6 #include "Core/Headers/Application.h"
8 7 #include "Core/Headers/ParamHandler.h"
8 + #include "Core/Headers/PlatformContext.h"
9 9 #include "Platform/Video/Headers/GFXDevice.h"
10 10 #include "Core/Resources/Headers/ResourceCache.h"
11 11 #include "Managers/Headers/RenderPassManager.h"
  @@ -19,18 +19,18 @@
19 19
20 20 namespace Divide {
21 21
22 - DeferredShadingRenderer::DeferredShadingRenderer(GFXDevice& context)
23 - : Renderer(context, RendererType::RENDERER_DEFERRED_SHADING), _cachedLightCount(0)
22 + DeferredShadingRenderer::DeferredShadingRenderer(PlatformContext& context, ResourceCache& cache)
23 + : Renderer(context, cache, RendererType::RENDERER_DEFERRED_SHADING), _cachedLightCount(0)
24 24 {
25 - _lightTexture = _context.newPB();
25 + _lightTexture = _context.gfx().newPB();
26 26 ResourceDescriptor deferred("DeferredShadingPass2");
27 27 deferred.setThreadedLoading(false);
28 - _deferredShader = CreateResource<ShaderProgram>(deferred);
29 - _deferredBuffer = _context.allocateRT("Deferred");
28 + _deferredShader = CreateResource<ShaderProgram>(cache, deferred);
29 + _deferredBuffer = _context.gfx().allocateRT("Deferred");
30 30
31 31 ResourceDescriptor deferredPreview("deferredPreview");
32 32 deferredPreview.setThreadedLoading(false);
33 - _previewDeferredShader = CreateResource<ShaderProgram>(deferredPreview);
33 + _previewDeferredShader = CreateResource<ShaderProgram>(cache, deferredPreview);
34 34 SamplerDescriptor gBufferSampler;
35 35 gBufferSampler.setWrapMode(TextureWrap::CLAMP_TO_EDGE);
36 36 gBufferSampler.setFilters(TextureFilter::NEAREST);
  @@ -76,24 +76,24 @@
76 76 mrt3.setFlag(true); // no default material
77 77 ResourceDescriptor mrt4("MRT RenderQuad4");
78 78 mrt4.setFlag(true); // no default material
79 - _renderQuads.push_back(CreateResource<Quad3D>(mrt));
80 - _renderQuads.push_back(CreateResource<Quad3D>(mrt2));
81 - _renderQuads.push_back(CreateResource<Quad3D>(mrt3));
82 - _renderQuads.push_back(CreateResource<Quad3D>(mrt4));
83 - _renderQuads.push_back(CreateResource<Quad3D>(mrtPreviewSmall));
79 + _renderQuads.push_back(CreateResource<Quad3D>(cache, mrt));
80 + _renderQuads.push_back(CreateResource<Quad3D>(cache, mrt2));
81 + _renderQuads.push_back(CreateResource<Quad3D>(cache, mrt3));
82 + _renderQuads.push_back(CreateResource<Quad3D>(cache, mrt4));
83 + _renderQuads.push_back(CreateResource<Quad3D>(cache, mrtPreviewSmall));
84 84
85 85 ParamHandler& par = ParamHandler::instance();
86 86 STUBBED("Shadow maps are currently disabled for Deferred Rendering! -Ionut")
87 87 par.setParam(_ID("rendering.enableShadows"), false);
88 88
89 - RenderTarget& screenRT = _context.renderTarget(RenderTargetID(RenderTargetUsage::SCREEN));
89 + RenderTarget& screenRT = _context.gfx().renderTarget(RenderTargetID(RenderTargetUsage::SCREEN));
90 90
91 91 U16 width = screenRT.getWidth();
92 92 U16 height = screenRT.getHeight();
93 93
94 94 updateResolution(width, height);
95 95
96 - GUI& gui = Application::instance().kernel().platformContext().gui();
96 + GUI& gui = _context.gui();
97 97 gui.addText(_ID("PositionData"), // Unique ID
98 98 vec2<I32>(60, 60), // Position
99 99 Font::DIVIDE_DEFAULT, // Font
  @@ -120,7 +120,7 @@
120 120 {
121 121 Console::printfn(Locale::get(_ID("DEFERRED_RT_DELETE")));
122 122 _renderQuads.clear();
123 - _context.deallocateRT(_deferredBuffer);
123 + _context.gfx().deallocateRT(_deferredBuffer);
124 124 _lightTexture->destroy();}
125 125
126 126 void DeferredShadingRenderer::preRender(RenderTarget& target, LightPool& lightPool) {
  @@ -172,7 +172,7 @@
172 172 // Pass 2
173 173 // Draw a 2D fullscreen quad with lighting shader applied and all generated
174 174 // textures bound to that shader
175 - GFX::Scoped2DRendering scoped2D;
175 + GFX::Scoped2DRendering scoped2D(_context.gfx());
176 176
177 177 _deferredBuffer._rt->bind(0, RTAttachment::Type::Colour, 0);
178 178 _deferredBuffer._rt->bind(1, RTAttachment::Type::Colour, 1);
  @@ -181,35 +181,35 @@
181 181 _lightTexture->bind(4);
182 182
183 183 GenericDrawCommand cmd;
184 - cmd.stateHash(_context.getDefaultStateBlock(true));
184 + cmd.stateHash(_context.gfx().getDefaultStateBlock(true));
185 185 cmd.shaderProgram(_previewDeferredShader);
186 186 if (_debugView) {
187 187 _previewDeferredShader->Uniform("texDiffuse0", 4);
188 - if (_renderQuads[1]->onRender(_context.getRenderStage())) {
188 + if (_renderQuads[1]->onRender(_context.gfx().getRenderStage())) {
189 189 cmd.sourceBuffer(_renderQuads[1]->getGeometryVB());
190 - _context.draw(cmd);
190 + _context.gfx().draw(cmd);
191 191 }
192 192 _previewDeferredShader->Uniform("texDiffuse0", 1);
193 - if (_renderQuads[2]->onRender(_context.getRenderStage())) {
193 + if (_renderQuads[2]->onRender(_context.gfx().getRenderStage())) {
194 194 cmd.sourceBuffer(_renderQuads[2]->getGeometryVB());
195 - _context.draw(cmd);
195 + _context.gfx().draw(cmd);
196 196 }
197 197 _previewDeferredShader->Uniform("texDiffuse0", 2);
198 - if (_renderQuads[3]->onRender(_context.getRenderStage())) {
198 + if (_renderQuads[3]->onRender(_context.gfx().getRenderStage())) {
199 199 cmd.sourceBuffer(_renderQuads[3]->getGeometryVB());
200 - _context.draw(cmd);
200 + _context.gfx().draw(cmd);
201 201 }
202 202 }
203 203
204 204 _deferredShader->Uniform("lightCount", (I32)_cachedLightCount);
205 205
206 206 cmd.shaderProgram(_deferredShader);
207 - if (_renderQuads[_debugView ? 4 : 0]->onRender(_context.getRenderStage())) {
207 + if (_renderQuads[_debugView ? 4 : 0]->onRender(_context.gfx().getRenderStage())) {
208 208 cmd.sourceBuffer(_renderQuads[_debugView ? 4 : 0]->getGeometryVB());
209 - _context.draw(cmd);
209 + _context.gfx().draw(cmd);
210 210 }
211 211
212 - GUI& gui = Application::instance().kernel().platformContext().gui();
212 + GUI& gui = _context.gui();
213 213 GUIElement* guiElement = gui.getGUIElement(0, _ID("FinalImage"));
214 214 if (guiElement) {
215 215 guiElement->setVisible(_debugView);