History

MOving forward on the background beeing drawn last

samcake committed 11 years ago

Commit dc3c9b41 parent 04115057 files · +182 −3Browse files

Showing the changes to libraries/render-utils/src/FramebufferCache.cpp (1 of 7 files). Show all

Unified · Split

libraries/render-utils/src/FramebufferCache.cpp+23−0
@@ -35,7 +35,9 @@ void FramebufferCache::setFrameBufferSize(QSize frameBufferSize) { · 34 unmodified lines
3535 _frameBufferSize = frameBufferSize;
3636 _primaryFramebufferFull.reset();
3737 _primaryFramebufferDepthColor.reset();
38+ _primaryFramebufferDepthStencilColor.reset();
3839 _primaryDepthTexture.reset();
40+ _primaryStencilTexture.reset();
3941 _primaryColorTexture.reset();
4042 _primaryNormalTexture.reset();
4143 _primarySpecularTexture.reset();
@@ -47,6 +49,7 @@ void FramebufferCache::setFrameBufferSize(QSize frameBufferSize) { · 5 unmodified lines
4749 void FramebufferCache::createPrimaryFramebuffer() {
4850 _primaryFramebufferFull = gpu::FramebufferPointer(gpu::Framebuffer::create());
4951 _primaryFramebufferDepthColor = gpu::FramebufferPointer(gpu::Framebuffer::create());
52+ _primaryFramebufferDepthStencilColor = gpu::FramebufferPointer(gpu::Framebuffer::create());
5053
5154 auto colorFormat = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA);
5255 auto width = _frameBufferSize.width();
@@ -63,12 +66,19 @@ void FramebufferCache::createPrimaryFramebuffer() { · 10 unmodified lines
6366
6467 _primaryFramebufferDepthColor->setRenderBuffer(0, _primaryColorTexture);
6568
69+ _primaryFramebufferDepthStencilColor->setRenderBuffer(0, _primaryColorTexture);
70+
6671 auto depthFormat = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH);
6772 _primaryDepthTexture = gpu::TexturePointer(gpu::Texture::create2D(depthFormat, width, height, defaultSampler));
6873
74+ auto stencilFormat = gpu::Element(gpu::VEC2, gpu::UINT32, gpu::DEPTH_STENCIL);
75+ _primaryStencilTexture = gpu::TexturePointer(gpu::Texture::create2D(stencilFormat, width, height, defaultSampler));
76+
6977 _primaryFramebufferFull->setDepthStencilBuffer(_primaryDepthTexture, depthFormat);
7078
7179 _primaryFramebufferDepthColor->setDepthStencilBuffer(_primaryDepthTexture, depthFormat);
80+
81+ _primaryFramebufferDepthStencilColor->setDepthStencilBuffer(_primaryStencilTexture, stencilFormat);
7282
7383 _selfieFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());
7484 auto tex = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width * 0.5, height * 0.5, defaultSampler));
@@ -89,6 +99,12 @@ gpu::FramebufferPointer FramebufferCache::getPrimaryFramebufferDepthColor() { · 14 unmodified lines
8999 return _primaryFramebufferDepthColor;
90100 }
91101
102+gpu::FramebufferPointer FramebufferCache::getPrimaryFramebufferDepthStencilColor() {
103+ if (!_primaryFramebufferDepthStencilColor) {
104+ createPrimaryFramebuffer();
105+ }
106+ return _primaryFramebufferDepthStencilColor;
107+}
92108
93109 gpu::TexturePointer FramebufferCache::getPrimaryDepthTexture() {
94110 if (!_primaryDepthTexture) {
@@ -97,6 +113,13 @@ gpu::TexturePointer FramebufferCache::getPrimaryDepthTexture() { · 2 unmodified lines
97113 return _primaryDepthTexture;
98114 }
99115
116+gpu::TexturePointer FramebufferCache::getPrimaryStencilTexture() {
117+ if (!_primaryStencilTexture) {
118+ createPrimaryFramebuffer();
119+ }
120+ return _primaryStencilTexture;
121+}
122+
100123 gpu::TexturePointer FramebufferCache::getPrimaryColorTexture() {
101124 if (!_primaryColorTexture) {
102125 createPrimaryFramebuffer();