mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-14 13:33:42 +00:00
Shuffled code, realised I wasn't actually binding my shader.
This commit is contained in:
parent
69984b54e5
commit
1b6754c5f8
@ -188,6 +188,16 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
|
|||||||
defaultFramebuffer = 0;
|
defaultFramebuffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lock down any further work on the current frame
|
||||||
|
_output_mutex->lock();
|
||||||
|
|
||||||
|
// release the mapping, giving up on trying to draw if data has been lost
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, output_array_buffer);
|
||||||
|
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, source_array_buffer);
|
||||||
|
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||||
|
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
|
||||||
|
|
||||||
// make sure there's a target to draw to
|
// make sure there's a target to draw to
|
||||||
if(!framebuffer || framebuffer->get_height() != output_height || framebuffer->get_width() != output_width)
|
if(!framebuffer || framebuffer->get_height() != output_height || framebuffer->get_width() != output_width)
|
||||||
{
|
{
|
||||||
@ -203,16 +213,6 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
|
|||||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, _input_texture_array);
|
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, _input_texture_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
// lock down any further work on the current frame
|
|
||||||
_output_mutex->lock();
|
|
||||||
|
|
||||||
// release the mapping, giving up on trying to draw if data has been lost
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, output_array_buffer);
|
|
||||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, source_array_buffer);
|
|
||||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
|
||||||
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
|
|
||||||
|
|
||||||
// upload more source pixel data if any; we'll always resubmit the last line submitted last
|
// upload more source pixel data if any; we'll always resubmit the last line submitted last
|
||||||
// time as it may have had extra data appended to it
|
// time as it may have had extra data appended to it
|
||||||
if(_buffer_builder->_write_y_position < _buffer_builder->last_uploaded_line)
|
if(_buffer_builder->_write_y_position < _buffer_builder->last_uploaded_line)
|
||||||
|
@ -75,7 +75,6 @@ void TextureTarget::draw(float aspect_ratio)
|
|||||||
"texCoordVarying = texCoord;"
|
"texCoordVarying = texCoord;"
|
||||||
"gl_Position = vec4(position, 0.0, 1.0);"
|
"gl_Position = vec4(position, 0.0, 1.0);"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
const char *fragment_shader =
|
const char *fragment_shader =
|
||||||
"#version 150\n"
|
"#version 150\n"
|
||||||
|
|
||||||
@ -85,7 +84,7 @@ void TextureTarget::draw(float aspect_ratio)
|
|||||||
|
|
||||||
"void main(void)"
|
"void main(void)"
|
||||||
"{"
|
"{"
|
||||||
"fragColour = vec4(0.5);"//texture(texID, texCoordVarying);"
|
"fragColour = texture(texID, texCoordVarying);"
|
||||||
"}";
|
"}";
|
||||||
_pixel_shader = std::unique_ptr<Shader>(new Shader(vertex_shader, fragment_shader, nullptr));
|
_pixel_shader = std::unique_ptr<Shader>(new Shader(vertex_shader, fragment_shader, nullptr));
|
||||||
|
|
||||||
@ -127,18 +126,18 @@ void TextureTarget::draw(float aspect_ratio)
|
|||||||
if(aspect_ratio_ratio >= 1.0f)
|
if(aspect_ratio_ratio >= 1.0f)
|
||||||
{
|
{
|
||||||
// output is thinner than we are; letterbox
|
// output is thinner than we are; letterbox
|
||||||
fl_buffer[0] = -1.0f; fl_buffer[1] = 1.0f / aspect_ratio_ratio;
|
fl_buffer[0] = -1.0f; fl_buffer[1] = -1.0f / aspect_ratio_ratio;
|
||||||
fl_buffer[3] = -1.0f; fl_buffer[4] = -1.0f / aspect_ratio_ratio;
|
fl_buffer[3] = 1.0f; fl_buffer[4] = -1.0f / aspect_ratio_ratio;
|
||||||
fl_buffer[6] = 1.0f; fl_buffer[7] = 1.0f / aspect_ratio_ratio;
|
fl_buffer[6] = -1.0f; fl_buffer[7] = 1.0f / aspect_ratio_ratio;
|
||||||
fl_buffer[9] = 1.0f; fl_buffer[10] = -1.0f / aspect_ratio_ratio;
|
fl_buffer[9] = 1.0f; fl_buffer[10] = 1.0f / aspect_ratio_ratio;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// output is wider than we are; pillarbox
|
// output is wider than we are; pillarbox
|
||||||
fl_buffer[0] = -aspect_ratio_ratio; fl_buffer[1] = 1.0f;
|
fl_buffer[0] = -aspect_ratio_ratio; fl_buffer[1] = -1.0f;
|
||||||
fl_buffer[3] = -aspect_ratio_ratio; fl_buffer[4] = -1.0f;
|
fl_buffer[3] = aspect_ratio_ratio; fl_buffer[4] = -1.0f;
|
||||||
fl_buffer[6] = aspect_ratio_ratio; fl_buffer[7] = 1.0f;
|
fl_buffer[6] = -aspect_ratio_ratio; fl_buffer[7] = 1.0f;
|
||||||
fl_buffer[9] = aspect_ratio_ratio; fl_buffer[10] = -1.0f;
|
fl_buffer[9] = aspect_ratio_ratio; fl_buffer[10] = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// upload buffer
|
// upload buffer
|
||||||
@ -146,6 +145,7 @@ void TextureTarget::draw(float aspect_ratio)
|
|||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(buffer), buffer, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, sizeof(buffer), buffer, GL_STATIC_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_pixel_shader->bind();
|
||||||
glBindVertexArray(_drawing_vertex_array);
|
glBindVertexArray(_drawing_vertex_array);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user