History

working version with the gpu::SAmpler and the gpu::Framebuffer

Sam Gateau committed 11 years ago

Commit 87030231 parent c34c5f611 files · +286 −116Browse files

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

Unified · Split

libraries/render-utils/src/TextureCache.cpp+8−25
@@ -259,9 +259,11 @@ void TextureCache::createPrimaryFramebuffer() { · 258 unmodified lines
259259 auto colorFormat = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA);
260260 auto width = _frameBufferSize.width();
261261 auto height = _frameBufferSize.height();
262− _primaryColorTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height));
263− _primaryNormalTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height));
264− _primarySpecularTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height));
262+
263+ auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_POINT);
264+ _primaryColorTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler));
265+ _primaryNormalTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler));
266+ _primarySpecularTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler));
265267
266268 _primaryOpaqueFramebuffer->setRenderBuffer(0, _primaryColorTexture);
267269 _primaryOpaqueFramebuffer->setRenderBuffer(1, _primaryNormalTexture);
@@ -270,7 +272,7 @@ void TextureCache::createPrimaryFramebuffer() { · 2 unmodified lines
270272 _primaryTransparentFramebuffer->setRenderBuffer(0, _primaryColorTexture);
271273
272274 auto depthFormat = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH);
273− _primaryDepthTexture = gpu::TexturePointer(gpu::Texture::create2D(depthFormat, width, height));
275+ _primaryDepthTexture = gpu::TexturePointer(gpu::Texture::create2D(depthFormat, width, height, defaultSampler));
274276
275277 _primaryOpaqueFramebuffer->setDepthStencilBuffer(_primaryDepthTexture, depthFormat);
276278
@@ -380,25 +382,6 @@ gpu::FramebufferPointer TextureCache::getShadowFramebuffer() { · 103 unmodified lines
380382 _shadowFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::createShadowmap(SHADOW_MAP_SIZE));
381383
382384 _shadowTexture = _shadowFramebuffer->getDepthStencilBuffer();
383− /*
384− glGenTextures(1, &_shadowDepthTextureID);
385− glBindTexture(GL_TEXTURE_2D, _shadowDepthTextureID);
386− glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, SHADOW_MAP_SIZE, SHADOW_MAP_SIZE,
387− 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0);
388− glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
389− glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
390− glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
391− glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
392− const float DISTANT_BORDER[] = { 1.0f, 1.0f, 1.0f, 1.0f };
393− glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, DISTANT_BORDER);
394− glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
395− glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
396− glBindTexture(GL_TEXTURE_2D, 0);
397−
398− _shadowFramebufferObject->bind();
399− glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, _shadowDepthTextureID, 0);
400− _shadowFramebufferObject->release();
401− */
402385 }
403386 return _shadowFramebuffer;
404387 }
@@ -675,7 +658,7 @@ void NetworkTexture::setImage(const QImage& image, bool translucent, const QColo · 270 unmodified lines
675658 formatGPU = gpu::Element(gpu::VEC4, gpu::UINT8, (isLinearRGB ? gpu::RGBA : gpu::SRGBA));
676659 formatMip = gpu::Element(gpu::VEC4, gpu::UINT8, (isLinearRGB ? gpu::BGRA : gpu::SBGRA));
677660 }
678− _gpuTexture = gpu::TexturePointer(gpu::Texture::create2D(formatGPU, image.width(), image.height()));
661+ _gpuTexture = gpu::TexturePointer(gpu::Texture::create2D(formatGPU, image.width(), image.height(), gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR)));
679662 _gpuTexture->assignStoredMip(0, formatMip, image.byteCount(), image.constBits());
680663 _gpuTexture->autoGenerateMips(-1);
681664 }
@@ -714,7 +697,7 @@ QSharedPointer<Texture> DilatableNetworkTexture::getDilatedTexture(float dilatio · 32 unmodified lines
714697 formatGPU = gpu::Element(gpu::VEC4, gpu::UINT8, (isLinearRGB ? gpu::RGBA : gpu::SRGBA));
715698 formatMip = gpu::Element(gpu::VEC4, gpu::UINT8, (isLinearRGB ? gpu::BGRA : gpu::BGRA));
716699 }
717− texture->_gpuTexture = gpu::TexturePointer(gpu::Texture::create2D(formatGPU, dilatedImage.width(), dilatedImage.height()));
700+ texture->_gpuTexture = gpu::TexturePointer(gpu::Texture::create2D(formatGPU, dilatedImage.width(), dilatedImage.height(), gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR)));
718701 texture->_gpuTexture->assignStoredMip(0, formatMip, dilatedImage.byteCount(), dilatedImage.constBits());
719702 texture->_gpuTexture->autoGenerateMips(-1);
720703