#include "bmusb/bmusb.h"
#include "context.h"
#include "defs.h"
+#include "flags.h"
#include "h264encode.h"
#include "pbo_frame_allocator.h"
#include "ref_counted_gl_sync.h"
display_chain->set_dither_bits(0); // Don't bother.
display_chain->finalize();
- h264_encoder.reset(new H264Encoder(h264_encoder_surface, WIDTH, HEIGHT, &httpd));
+ h264_encoder.reset(new H264Encoder(h264_encoder_surface, global_flags.va_display, WIDTH, HEIGHT, &httpd));
for (unsigned card_index = 0; card_index < num_cards; ++card_index) {
printf("Configuring card %d...\n", card_index);
"#version 130 \n"
"in vec2 tc0; \n"
"uniform sampler2D cbcr_tex; \n"
+ "out vec4 FragColor; \n"
"void main() { \n"
- " gl_FragColor = texture2D(cbcr_tex, tc0); \n"
+ " FragColor = texture(cbcr_tex, tc0); \n"
"} \n";
vector<string> frag_shader_outputs;
cbcr_program_num = resource_pool->compile_glsl_program(cbcr_vert_shader, cbcr_frag_shader, frag_shader_outputs);
+ float vertices[] = {
+ 0.0f, 2.0f,
+ 0.0f, 0.0f,
+ 2.0f, 0.0f
+ };
+ cbcr_vbo = generate_vbo(2, GL_FLOAT, sizeof(vertices), vertices);
+ cbcr_position_attribute_index = glGetAttribLocation(cbcr_program_num, "position");
+ cbcr_texcoord_attribute_index = glGetAttribLocation(cbcr_program_num, "texcoord");
+
r128.init(2, OUTPUT_FREQUENCY);
r128.integr_start();
Mixer::~Mixer()
{
resource_pool->release_glsl_program(cbcr_program_num);
+ glDeleteBuffers(1, &cbcr_vbo);
BMUSBCapture::stop_bm_thread();
for (unsigned card_index = 0; card_index < num_cards; ++card_index) {
check_error();
glBindTexture(GL_TEXTURE_2D, 0);
check_error();
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
+ check_error();
GLsync fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, /*flags=*/0);
check_error();
assert(fence != nullptr);
h264_encoder->shutdown();
httpd.close_output_file();
httpd.open_output_file(filename.c_str());
- h264_encoder.reset(new H264Encoder(h264_encoder_surface, WIDTH, HEIGHT, &httpd));
+ h264_encoder.reset(new H264Encoder(h264_encoder_surface, global_flags.va_display, WIDTH, HEIGHT, &httpd));
}
#if 0
glGenVertexArrays(1, &vao);
check_error();
- float vertices[] = {
- 0.0f, 2.0f,
- 0.0f, 0.0f,
- 2.0f, 0.0f
- };
-
glBindVertexArray(vao);
check_error();
float chroma_offset_0[] = { -0.5f / WIDTH, 0.0f };
set_uniform_vec2(cbcr_program_num, "foo", "chroma_offset_0", chroma_offset_0);
- GLuint position_vbo = fill_vertex_attribute(cbcr_program_num, "position", 2, GL_FLOAT, sizeof(vertices), vertices);
- GLuint texcoord_vbo = fill_vertex_attribute(cbcr_program_num, "texcoord", 2, GL_FLOAT, sizeof(vertices), vertices); // Same as vertices.
+ glBindBuffer(GL_ARRAY_BUFFER, cbcr_vbo);
+ check_error();
+
+ for (GLint attr_index : { cbcr_position_attribute_index, cbcr_texcoord_attribute_index }) {
+ glEnableVertexAttribArray(attr_index);
+ check_error();
+ glVertexAttribPointer(attr_index, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
+ check_error();
+ }
glDrawArrays(GL_TRIANGLES, 0, 3);
check_error();
- cleanup_vertex_attribute(cbcr_program_num, "position", position_vbo);
- cleanup_vertex_attribute(cbcr_program_num, "texcoord", texcoord_vbo);
+ for (GLint attr_index : { cbcr_position_attribute_index, cbcr_texcoord_attribute_index }) {
+ glDisableVertexAttribArray(attr_index);
+ check_error();
+ }
glUseProgram(0);
check_error();
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ check_error();
resource_pool->release_fbo(fbo);
glDeleteVertexArrays(1, &vao);