Debian Codegraph @

tests/manual/deferred-renderer-cpp/gbuffer.cpp

raw symbols SCIP
1 // Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 #include "gbuffer.h"
5
6 GBuffer::GBuffer(Qt3DCore::QNode *parent)
7 : Qt3DRender::QRenderTarget(parent)
8 {
9 const Qt3DRender::QAbstractTexture::TextureFormat formats[AttachmentsCount] = {
10 Qt3DRender::QAbstractTexture::RGBA32F,
11 // We use RGBA32F for the following two instead of a more fitting format because
12 // OpenGL vendors might not support other formats
13 Qt3DRender::QAbstractTexture::RGBA32F,
14 Qt3DRender::QAbstractTexture::RGBA32F,
15 Qt3DRender::QAbstractTexture::D32F
16 };
17
18 const Qt3DRender::QRenderTargetOutput::AttachmentPoint attachmentPoints[AttachmentsCount] = {
19 Qt3DRender::QRenderTargetOutput::Color0,
20 Qt3DRender::QRenderTargetOutput::Color1,
21 Qt3DRender::QRenderTargetOutput::Color2,
22 Qt3DRender::QRenderTargetOutput::Depth
23 };
24
25 for (int i = 0; i < AttachmentsCount; i++) {
26 Qt3DRender::QRenderTargetOutput *output = new Qt3DRender::QRenderTargetOutput(this);
27
28 m_textures[i] = new Qt3DRender::QTexture2D();
29 m_textures[i]->setFormat(formats[i]);
30 m_textures[i]->setWidth(1024);
31 m_textures[i]->setHeight(1024);
32 m_textures[i]->setGenerateMipMaps(false);
33 m_textures[i]->setWrapMode(Qt3DRender::QTextureWrapMode(Qt3DRender::QTextureWrapMode::ClampToEdge));
34 m_textures[i]->setMinificationFilter(Qt3DRender::QAbstractTexture::Linear);
35 m_textures[i]->setMagnificationFilter(Qt3DRender::QAbstractTexture::Linear);
36
37 output->setTexture(m_textures[i]);
38 output->setAttachmentPoint(attachmentPoints[i]);
39 addOutput(output);
40 }
41 }
42
43 Qt3DRender::QAbstractTexture *GBuffer::colorTexture() const
44 {
45 return m_textures[Color];
46 }
47
48 Qt3DRender::QAbstractTexture *GBuffer::positionTexture() const
49 {
50 return m_textures[Position];
51 }
52
53 Qt3DRender::QAbstractTexture *GBuffer::normalTexture() const
54 {
55 return m_textures[Normal];
56 }
57
58 Qt3DRender::QAbstractTexture *GBuffer::depthTexture() const
59 {
60 return m_textures[Depth];
61 }