• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

graphia-app / graphia / 40899748389

29 Oct 2026 03:15PM UTC coverage: 69.612% (+0.02%) from 69.589%
40899748389

push

github

timangus
blah

11615 of 18200 branches covered (63.82%)

Branch coverage included in aggregate %.

818 of 2594 new or added lines in 59 files covered. (31.53%)

603 existing lines in 16 files now uncovered.

30075 of 41689 relevant lines covered (72.14%)

475617.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/source/app/layout/gpu/texelarrayframebuffer.cpp
1
/* Copyright © 2013-2025 Tim Angus
2
 * Copyright © 2013-2025 Tom Freeman
3
 *
4
 * This file is part of Graphia.
5
 *
6
 * Graphia is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * Graphia is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with Graphia.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19

20
#include "texelarrayframebuffer.h"
21

22
#include "texelarray.h"
23

24
#include <array>
25

26
TexelArrayFramebuffer::TexelArrayFramebuffer()
27
{
860 ✔
28
    resolveOpenGLFunctions();
860 ✔
29
    glGenFramebuffers(1, &_framebuffer);
860 ✔
30
}
860 ✔
31

32
TexelArrayFramebuffer::~TexelArrayFramebuffer()
33
{
860 ✔
34
    glDeleteFramebuffers(1, &_framebuffer);
860 ✔
35
}
860 ✔
36

37
void TexelArrayFramebuffer::attach(std::span<TexelArray* const> targets)
38
{
149,816 ✔
39
    glBindFramebuffer(GL_FRAMEBUFFER, _framebuffer);
149,816 ✔
40

41
    for(size_t i = 0; i < targets.size(); i++)
373,336 ✔
42
    {
223,520 ✔
43
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + static_cast<GLenum>(i),
223,520 ✔
44
            GL_TEXTURE_2D, targets[i]->texture(), 0);
223,520 ✔
45
    }
223,520 ✔
46

47
    // Only what was attached before is detached, which keeps within the
48
    // attachments a device has
49
    for(size_t i = targets.size(); i < _numAttached; i++)
223,376 ✔
50
    {
73,560 ✔
51
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + static_cast<GLenum>(i),
73,560 ✔
52
            GL_TEXTURE_2D, 0, 0);
73,560 ✔
53
    }
73,560 ✔
54

55
    _numAttached = targets.size();
149,816 ✔
56
}
149,816 ✔
57

58
void TexelArrayFramebuffer::drawInto(std::span<TexelArray* const> targets)
59
{
147,408 ✔
60
    attach(targets);
147,408 ✔
61

62
    std::array<GLenum, 4> drawBuffers = {};
147,408 ✔
63

64
    for(size_t i = 0; i < targets.size(); i++)
368,520 ✔
65
        drawBuffers.at(i) = GL_COLOR_ATTACHMENT0 + static_cast<GLenum>(i);
221,112 ✔
66

67
    glDrawBuffers(static_cast<GLsizei>(targets.size()), drawBuffers.data());
147,408 ✔
68
    glViewport(0, 0, targets.front()->width(), targets.front()->height());
147,408 ✔
69
}
147,408 ✔
70

71
void TexelArrayFramebuffer::drawInto(std::initializer_list<TexelArray*> targets)
72
{
147,408 ✔
73
    drawInto(std::span(targets.begin(), targets.size()));
147,408 ✔
74
}
147,408 ✔
75

76
void TexelArrayFramebuffer::copyRows(TexelArray& destination, int firstRow, int numRows)
NEW
77
{
×
NEW
78
    glReadBuffer(GL_COLOR_ATTACHMENT0);
×
NEW
79
    glBindTexture(GL_TEXTURE_2D, destination.texture());
×
NEW
80
    glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, firstRow, 0, firstRow, destination.width(), numRows);
×
NEW
81
    glBindTexture(GL_TEXTURE_2D, 0);
×
NEW
82
}
×
83

84
void TexelArrayFramebuffer::readFrom(TexelArray& source)
85
{
2,408 ✔
86
    std::array<TexelArray*, 1> targets = {&source};
2,408 ✔
87
    attach(targets);
2,408 ✔
88
    glReadBuffer(GL_COLOR_ATTACHMENT0);
89
}
2,408 ✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc