Chrysalis - Renderer Test Coverage


renderer/
File: renderer/src/BaseOpenGLProgram.cpp
Date: 2026-08-27 18:35:31
Lines:
0/59
0.0%
Functions:
0/10
0.0%
Branches:
0/54
0.0%
Decisions:
0/4
0.0%
Calls:
0/113
0.0%

Line Branch Decision Call Exec Source
1 #include "BaseOpenGLProgram.h"
2
3
4 #include "Logging.h"
5 #define LOGGER_NAME "OpenGL Program"
6
7 using namespace Chrysalis;
8
9
0/1
✗ Call 0 not invoked.
✗ BaseOpenGLProgram::BaseOpenGLProgram(const char* vertexShader, const char* fragmentShader)
10
0/5
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ : vertexShader_(vertexShader), fragmentShader_(fragmentShader) {}
11
12 ✗ BaseOpenGLProgram::~BaseOpenGLProgram() {
13
0/3
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ glDeleteProgram(program_);
14
0/1
✗ Call 0 not invoked.
✗ }
15
16 ✗ GLint BaseOpenGLProgram::prepareShader(const char* shaderCode, const GLenum shaderType) {
17
0/1
✗ Call 0 not invoked.
✗ const GLint shader = glCreateShader(shaderType);
18
0/1
✗ Call 0 not invoked.
✗ glShaderSource(shader, 1, &shaderCode, nullptr);
19
0/1
✗ Call 0 not invoked.
✗ glCompileShader(shader);
20
21
0/1
✗ Call 0 not invoked.
✗ GLint ok = 0;
22
0/1
✗ Call 0 not invoked.
✗ glGetShaderiv(shader, GL_COMPILE_STATUS, &ok);
23
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (!ok) {
24
0/1
✗ Call 0 not invoked.
✗ GLint len = 0;
25
0/1
✗ Call 0 not invoked.
✗ glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len);
26
0/5
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ std::vector<char> log(static_cast<size_t>(len));
27
0/2
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ glGetShaderInfoLog(shader, len, nullptr, log.data());
28
0/1
✗ Call 0 not invoked.
✗ glDeleteShader(shader);
29
30
0/9
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
✗ LOG_CRITICAL("Failed to compile vertex shader. Error log: {}.", log.data());
31
0/2
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ }
32
0/1
✗ Call 0 not invoked.
✗ return shader;
33 }
34
35 ✗ void BaseOpenGLProgram::initialize() {
36
0/2
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ const GLint vertexShader = prepareShader(vertexShader_, GL_VERTEX_SHADER);
37
0/3
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ const GLint fragmentShader = prepareShader(fragmentShader_, GL_FRAGMENT_SHADER);
38
39
0/3
✗ Call 0 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ program_ = glCreateProgram();
40
0/3
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ glAttachShader(program_, vertexShader);
41
0/3
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ glAttachShader(program_, fragmentShader);
42
0/3
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ glLinkProgram(program_);
43
44
0/1
✗ Call 0 not invoked.
✗ GLint ok = 0;
45
0/3
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ glGetProgramiv(program_, GL_LINK_STATUS, &ok);
46
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (!ok) {
47
0/1
✗ Call 0 not invoked.
✗ GLint len = 0;
48
0/3
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ glGetProgramiv(program_, GL_INFO_LOG_LENGTH, &len);
49
0/5
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ std::vector<char> log(static_cast<size_t>(len));
50
0/4
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ glGetProgramInfoLog(program_, len, nullptr, log.data());
51
0/3
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ glDeleteProgram(program_);
52
0/2
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ program_ = 0;
53
54
0/9
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
✗ LOG_CRITICAL("Failed to link OpenGL program. Error log: {}.", log.data());
55
0/2
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ }
56
57
0/1
✗ Call 0 not invoked.
✗ glDeleteShader(vertexShader);
58
0/1
✗ Call 0 not invoked.
✗ glDeleteShader(fragmentShader);
59 ✗ }
60
61 ✗ void BaseOpenGLProgram::bind() const {
62
0/3
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ glUseProgram(program_);
63 ✗ }
64
65 ✗ void BaseOpenGLProgram::release() {
66
0/1
✗ Call 0 not invoked.
✗ glUseProgram(0);
67 ✗ }
68
69 ✗ void BaseOpenGLProgram::setUniformValue(const char* name, const GLint value) const {
70
0/4
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ glUniform1i(glGetUniformLocation(program_, name), value);
71 ✗ }
72
73 ✗ void BaseOpenGLProgram::setUniformValue(const char* name, const GLfloat value) const {
74
0/4
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ glUniform1f(glGetUniformLocation(program_, name), value);
75 ✗ }
76
77 ✗ void BaseOpenGLProgram::setUniformValue(const char* name, const glm::mat4x4& value) const {
78
0/8
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ glUniformMatrix4fv(glGetUniformLocation(program_, name), 1, GL_FALSE, &value[0][0]);
79 ✗ }
80
81 ✗ void BaseOpenGLProgram::setUniformValue(const char* name, const GLfloat x, const GLfloat y, const GLfloat z, const GLfloat w) const {
82
0/4
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ glUniform4f(glGetUniformLocation(program_, name), x, y, z, w);
83 ✗ }
84