From 04d1b65c93221195d818187061a419274c1be684 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 12 Apr 2016 22:48:47 -0400 Subject: [PATCH] Reinstated texture target creation, cut them down to merely RGB. --- Outputs/CRT/Internals/CRTOpenGL.cpp | 19 +++++++++++-------- Outputs/CRT/Internals/TextureTarget.cpp | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Outputs/CRT/Internals/CRTOpenGL.cpp b/Outputs/CRT/Internals/CRTOpenGL.cpp index fc11a12ad..b21dc0e22 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.cpp +++ b/Outputs/CRT/Internals/CRTOpenGL.cpp @@ -62,6 +62,14 @@ OpenGLOutputBuilder::OpenGLOutputBuilder(unsigned int buffer_depth) : } _buffer_builder = std::unique_ptr(new CRTInputBufferBuilder(buffer_depth)); + // Create intermediate textures and bind to slots 0, 1 and 2 + glActiveTexture(GL_TEXTURE0); + compositeTexture = std::unique_ptr(new OpenGL::TextureTarget(IntermediateBufferWidth, IntermediateBufferHeight)); + glActiveTexture(GL_TEXTURE1); + filteredYTexture = std::unique_ptr(new OpenGL::TextureTarget(IntermediateBufferWidth, IntermediateBufferHeight)); + glActiveTexture(GL_TEXTURE2); + filteredTexture = std::unique_ptr(new OpenGL::TextureTarget(IntermediateBufferWidth, IntermediateBufferHeight)); + // create the surce texture glGenTextures(1, &textureName); glActiveTexture(GL_TEXTURE0 + first_supplied_buffer_texture_unit); @@ -92,14 +100,6 @@ OpenGLOutputBuilder::OpenGLOutputBuilder(unsigned int buffer_depth) : // map that buffer too, for any CRT activity that may occur before the first draw _output_buffer_data = (uint8_t *)glMapBufferRange(GL_ARRAY_BUFFER, 0, OutputVertexBufferDataSize, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT); - - // Create intermediate textures and bind to slots 0, 1 and 2 -// glActiveTexture(GL_TEXTURE0); -// compositeTexture = std::unique_ptr(new OpenGL::TextureTarget(IntermediateBufferWidth, IntermediateBufferHeight)); -// glActiveTexture(GL_TEXTURE1); -// filteredYTexture = std::unique_ptr(new OpenGL::TextureTarget(IntermediateBufferWidth, IntermediateBufferHeight)); -// glActiveTexture(GL_TEXTURE2); -// filteredTexture = std::unique_ptr(new OpenGL::TextureTarget(IntermediateBufferWidth, IntermediateBufferHeight)); } OpenGLOutputBuilder::~OpenGLOutputBuilder() @@ -134,6 +134,9 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out // or 0 if no framebuffer is bound, in which case 0 is also what we want to supply to bind the implied framebuffer. So // it works either way. glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint *)&defaultFramebuffer); + + // TODO: is this sustainable, cross-platform? If so, why store it at all? + defaultFramebuffer = 0; } // lock down any further work on the current frame diff --git a/Outputs/CRT/Internals/TextureTarget.cpp b/Outputs/CRT/Internals/TextureTarget.cpp index 60c030f47..5a622e09b 100644 --- a/Outputs/CRT/Internals/TextureTarget.cpp +++ b/Outputs/CRT/Internals/TextureTarget.cpp @@ -18,8 +18,8 @@ TextureTarget::TextureTarget(GLsizei width, GLsizei height) : _width(width), _he glGenTextures(1, &_texture); glBindTexture(GL_TEXTURE_2D, _texture); - uint8_t *emptySpace = new uint8_t[width*height*4]; - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)width, (GLsizei)height, 0, GL_RGBA, GL_UNSIGNED_BYTE, emptySpace); + uint8_t *emptySpace = new uint8_t[width*height*3]; + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (GLsizei)width, (GLsizei)height, 0, GL_RGB, GL_UNSIGNED_BYTE, emptySpace); delete[] emptySpace; glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texture, 0);