mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-28 06:29:37 +00:00
Discovered cause of clears: stale code. Tweaked persistence, again.
This commit is contained in:
parent
09ed8eb654
commit
c93bcf9f28
@ -101,7 +101,7 @@ OpenGLOutputBuilder::OpenGLOutputBuilder(unsigned int buffer_depth) :
|
|||||||
_buffer_builder = std::unique_ptr<CRTInputBufferBuilder>(new CRTInputBufferBuilder(buffer_depth));
|
_buffer_builder = std::unique_ptr<CRTInputBufferBuilder>(new CRTInputBufferBuilder(buffer_depth));
|
||||||
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_CONSTANT_COLOR);
|
glBlendFunc(GL_SRC_ALPHA, GL_CONSTANT_COLOR);
|
||||||
glBlendColor(0.4f, 0.4f, 0.4f, 0.5f);
|
glBlendColor(0.6f, 0.6f, 0.6f, 1.0f);
|
||||||
|
|
||||||
// Create intermediate textures and bind to slots 0, 1 and 2
|
// Create intermediate textures and bind to slots 0, 1 and 2
|
||||||
compositeTexture = std::unique_ptr<OpenGL::TextureTarget>(new OpenGL::TextureTarget(IntermediateBufferWidth, IntermediateBufferHeight, composite_texture_unit));
|
compositeTexture = std::unique_ptr<OpenGL::TextureTarget>(new OpenGL::TextureTarget(IntermediateBufferWidth, IntermediateBufferHeight, composite_texture_unit));
|
||||||
@ -206,7 +206,13 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
|
|||||||
if(framebuffer)
|
if(framebuffer)
|
||||||
{
|
{
|
||||||
new_framebuffer->bind_framebuffer();
|
new_framebuffer->bind_framebuffer();
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
glActiveTexture(pixel_accumulation_texture_unit);
|
||||||
|
framebuffer->bind_texture();
|
||||||
framebuffer->draw((float)output_width / (float)output_height);
|
framebuffer->draw((float)output_width / (float)output_height);
|
||||||
|
|
||||||
|
new_framebuffer->bind_texture();
|
||||||
}
|
}
|
||||||
framebuffer = std::move(new_framebuffer);
|
framebuffer = std::move(new_framebuffer);
|
||||||
glActiveTexture(source_data_texture_unit);
|
glActiveTexture(source_data_texture_unit);
|
||||||
@ -303,6 +309,13 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
|
|||||||
else
|
else
|
||||||
perform_output_stage(output_width, output_height, rgb_shader_program.get());
|
perform_output_stage(output_width, output_height, rgb_shader_program.get());
|
||||||
|
|
||||||
|
// copy framebuffer to the intended place
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
glViewport(0, 0, (GLsizei)output_width, (GLsizei)output_height);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
framebuffer->draw((float)output_width / (float)output_height);
|
||||||
|
|
||||||
// drawing commands having been issued, reclaim the array buffer pointer
|
// drawing commands having been issued, reclaim the array buffer pointer
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, output_array_buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, output_array_buffer);
|
||||||
_output_buffer_data = (uint8_t *)glMapBufferRange(GL_ARRAY_BUFFER, 0, OutputVertexBufferDataSize, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
|
_output_buffer_data = (uint8_t *)glMapBufferRange(GL_ARRAY_BUFFER, 0, OutputVertexBufferDataSize, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
|
||||||
@ -340,7 +353,6 @@ void OpenGLOutputBuilder::perform_output_stage(unsigned int output_width, unsign
|
|||||||
// update uniforms (implicitly binding the shader)
|
// update uniforms (implicitly binding the shader)
|
||||||
if(_last_output_width != output_width || _last_output_height != output_height)
|
if(_last_output_width != output_width || _last_output_height != output_height)
|
||||||
{
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
shader->set_output_size(output_width, output_height, _visible_area);
|
shader->set_output_size(output_width, output_height, _visible_area);
|
||||||
_last_output_width = output_width;
|
_last_output_width = output_width;
|
||||||
_last_output_height = output_height;
|
_last_output_height = output_height;
|
||||||
@ -353,11 +365,6 @@ void OpenGLOutputBuilder::perform_output_stage(unsigned int output_width, unsign
|
|||||||
glDrawArrays(GL_TRIANGLE_STRIP, drawing_zones[c*2] / OutputVertexSize, drawing_zones[c*2 + 1] / OutputVertexSize);
|
glDrawArrays(GL_TRIANGLE_STRIP, drawing_zones[c*2] / OutputVertexSize, drawing_zones[c*2 + 1] / OutputVertexSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy to the intended place
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
framebuffer->draw((float)output_width / (float)output_height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ std::unique_ptr<OutputShader> OutputShader::make_shader(const char *fragment_met
|
|||||||
|
|
||||||
"void main(void)"
|
"void main(void)"
|
||||||
"{"
|
"{"
|
||||||
"fragColour = vec4(%s, 0.7*cos(lateralVarying));"
|
"fragColour = vec4(%s, 0.5*cos(lateralVarying));"
|
||||||
"}",
|
"}",
|
||||||
sampler_type, fragment_methods, colour_expression);
|
sampler_type, fragment_methods, colour_expression);
|
||||||
|
|
||||||
|
@ -124,25 +124,14 @@ void TextureTarget::draw(float aspect_ratio)
|
|||||||
buffer[14] = buffer[10];
|
buffer[14] = buffer[10];
|
||||||
buffer[15] = buffer[7];
|
buffer[15] = buffer[7];
|
||||||
|
|
||||||
// determine positions
|
// determine positions; rule is to keep the same height and centre
|
||||||
float internal_aspect_ratio = (float)_width / (float)_height;
|
float internal_aspect_ratio = (float)_width / (float)_height;
|
||||||
float aspect_ratio_ratio = internal_aspect_ratio / aspect_ratio;
|
float aspect_ratio_ratio = internal_aspect_ratio / aspect_ratio;
|
||||||
if(aspect_ratio_ratio >= 1.0f)
|
|
||||||
{
|
buffer[0] = -aspect_ratio_ratio; buffer[1] = -1.0f;
|
||||||
// output is thinner than we are; letterbox
|
buffer[4] = -aspect_ratio_ratio; buffer[5] = 1.0f;
|
||||||
buffer[0] = -1.0f; buffer[1] = -1.0f / aspect_ratio_ratio;
|
buffer[8] = aspect_ratio_ratio; buffer[9] = -1.0f;
|
||||||
buffer[4] = -1.0f; buffer[5] = 1.0f / aspect_ratio_ratio;
|
buffer[12] = aspect_ratio_ratio; buffer[13] = 1.0f;
|
||||||
buffer[8] = 1.0f; buffer[9] = -1.0f / aspect_ratio_ratio;
|
|
||||||
buffer[12] = 1.0f; buffer[13] = 1.0f / aspect_ratio_ratio;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// output is wider than we are; pillarbox
|
|
||||||
buffer[0] = -aspect_ratio_ratio; buffer[1] = -1.0f;
|
|
||||||
buffer[4] = -aspect_ratio_ratio; buffer[5] = 1.0f;
|
|
||||||
buffer[8] = aspect_ratio_ratio; buffer[9] = -1.0f;
|
|
||||||
buffer[12] = aspect_ratio_ratio; buffer[13] = 1.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// upload buffer
|
// upload buffer
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, _drawing_array_buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, _drawing_array_buffer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user