void Framebuffer::resize(const vec2i& sz) { if (_description.size.xy() == sz) return; forceSize(sz); bool hasColor = (_description.colorInternalformat != TextureFormat::Invalid) && (_description.colorIsRenderbuffer || (_description.colorFormat != TextureFormat::Invalid)); bool hasDepth = (_description.depthInternalformat != TextureFormat::Invalid) && (_description.depthIsRenderbuffer || (_description.depthFormat != TextureFormat::Invalid)); if (hasColor) { if (_description.colorIsRenderbuffer) { for (uint32_t& renderBuffer : _colorRenderBuffers) renderBuffer = buildColorRenderbuffer(renderBuffer); } else { for (auto rt : _renderTargets) { TextureDescription::Pointer desc = rt->description(); desc->size = sz; desc->data.resize(desc->layersCount * desc->dataSizeForAllMipLevels()); desc->data.fill(0); rt->updateData(_rc, desc); setCurrentRenderTarget(rt); } } } if (hasDepth) { if (_description.depthIsRenderbuffer) { createOrUpdateDepthRenderbuffer(); } else if (_depthBuffer.valid()) { auto desc = _depthBuffer->description(); desc->size = sz; desc->data.resize(desc->layersCount * desc->dataSizeForAllMipLevels()); desc->data.fill(0); _depthBuffer->updateData(_rc, desc); setDepthTarget(_depthBuffer); } } if (hasColor || hasDepth) checkStatus(); }
Texture::Pointer TextureFactory::genCubeTexture(TextureFormat internalformat, uint32_t size, TextureFormat format, DataType type, const std::string& aName) { TextureDescription::Pointer desc = TextureDescription::Pointer::create(); desc->target = TextureTarget::Texture_Cube; desc->format = format; desc->internalformat = internalformat; desc->type = type; desc->size = vec2i(size); desc->mipMapCount = 1; desc->layersCount = 6; desc->bitsPerPixel = bitsPerPixelForTextureFormat(internalformat, type); desc->data = BinaryDataStorage(desc->layersCount * desc->dataSizeForAllMipLevels(), 0); return Texture::Pointer::create(renderContext(), desc, aName, false); }