summaryrefslogtreecommitdiff
path: root/test/testRenderOutput.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-12-29 23:25:25 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-12-29 23:25:25 +0000
commit94e99a5a9ded01e8184543b7ddf5cdfa39573ded (patch)
treeca6dd314da3c3d29fd8fc8d36f53d578c8c48be6 /test/testRenderOutput.cpp
parentAdd missing explicit on constructors (diff)
downloadilt-94e99a5a9ded01e8184543b7ddf5cdfa39573ded.tar.bz2
ilt-94e99a5a9ded01e8184543b7ddf5cdfa39573ded.tar.xz
ilt-94e99a5a9ded01e8184543b7ddf5cdfa39573ded.zip
Move test render helpers into a new test library
Diffstat (limited to 'test/testRenderOutput.cpp')
-rw-r--r--test/testRenderOutput.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/testRenderOutput.cpp b/test/testRenderOutput.cpp
new file mode 100644
index 0000000..7a96e96
--- /dev/null
+++ b/test/testRenderOutput.cpp
@@ -0,0 +1,26 @@
+#include "testRenderOutput.h"
+#include <stdexcept>
+
+TestRenderOutput::TestRenderOutput() : size {640, 480}
+{
+ glBindFramebuffer(GL_FRAMEBUFFER, output);
+ const auto configuregdata
+ = [this](const GLuint data, const GLint format, const GLenum type, const GLenum attachment) {
+ glBindTexture(GL_TEXTURE_2D, data);
+ glTexImage2D(GL_TEXTURE_2D, 0, format, size.x, size.y, 0, GL_RGBA, type, NULL);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, data, 0);
+ };
+ configuregdata(outImage, GL_RGBA, GL_UNSIGNED_BYTE, GL_COLOR_ATTACHMENT0);
+ glDrawBuffer(GL_COLOR_ATTACHMENT0);
+
+ glBindRenderbuffer(GL_RENDERBUFFER, depth);
+ glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, size.x, size.y);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth);
+
+ // finally check if framebuffer is complete
+ if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
+ throw std::runtime_error("Framebuffer not complete!");
+ }
+}