1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-06 01:28:57 +00:00

Attempted to deal with the precision issues causing 'television' output currently to differ from 'monitor' output. Documented TextureTarget while I'm here.

This commit is contained in:
Thomas Harte 2016-04-19 20:51:34 -04:00
parent 6f52ed14d6
commit 20aa9e291d
2 changed files with 22 additions and 2 deletions

View File

@ -229,6 +229,7 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
}
// transfer to screen
glFinish();
glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
compositeTexture->bind_texture();
perform_output_stage(output_width, output_height, composite_output_shader_program.get());
@ -362,12 +363,12 @@ char *OpenGLOutputBuilder::get_input_vertex_shader()
"{"
"ivec2 textureSize = textureSize(texID, 0);"
"iInputPositionVarying = inputPosition;"
"inputPositionVarying = inputPosition / vec2(textureSize);" // + 0.5
"inputPositionVarying = (inputPosition + vec2(0.0, 0.5)) / vec2(textureSize);"
"phaseVarying = (phaseCyclesPerTick * phaseTime + phaseAmplitudeAndAlpha.x) * 2.0 * 3.141592654;"
"alphaVarying = phaseAmplitudeAndAlpha.z;"
"vec2 eyePosition = 2.0*(outputPosition / outputTextureSize) - vec2(1.0);"
"vec2 eyePosition = 2.0*(outputPosition / outputTextureSize) - vec2(1.0) + vec2(0.5)/textureSize;"
"gl_Position = vec4(eyePosition, 0.0, 1.0);"
"}");
}

View File

@ -13,12 +13,31 @@
namespace OpenGL {
/*!
A @c TextureTarget is a framebuffer that can be bound as a texture. So this class
handles render-to-texture framebuffer objects.
*/
class TextureTarget {
public:
/*!
Creates a new texture target.
Throws ErrorFramebufferIncomplete if creation fails.
@param width The width of target to create.
@param height The height of target to create.
*/
TextureTarget(GLsizei width, GLsizei height);
~TextureTarget();
/*!
Binds this target as a framebuffer and sets the @c glViewport accordingly.
*/
void bind_framebuffer();
/*!
Binds this target as a texture.
*/
void bind_texture();
enum {