else
// Copy to RAM
{
- command->input->enable_opengl();
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE,
- command->frame->get_rows()[0]);
- command->frame->flip_vert();
- command->frame->set_opengl_state(VFrame::RAM);
+ command->input->to_texture();
+ command->input->bind_texture(0);
+ command->frame->enable_opengl();
+ command->frame->init_screen();
+ unsigned int shader = BC_CModels::is_yuv(command->input->get_color_model()) ?
+ VFrame::make_shader(0, yuv_to_rgb_frag, 0) : 0;
+ if( shader > 0 ) {
+ glUseProgram(shader);
+ int variable = glGetUniformLocation(shader, "tex");
+ glUniform1i(variable, 0);
+ BC_GL_YUV_TO_RGB(shader);
+ }
+ else
+ glUseProgram(0);
+ command->input->draw_texture(1);
+ command->frame->screen_to_ram();
+ glUseProgram(0);
}
}
else
// Make sure OpenGL is enabled first.
window->enable_opengl();
-
//printf("Playback3D::write_buffer_sync 1 %d\n", window->get_id());
- switch(command->frame->get_opengl_state())
- {
+ int flip_y = 0, frame_state = command->frame->get_opengl_state();
+ switch( frame_state ) {
// Upload texture and composite to screen
case VFrame::RAM:
+ flip_y = 1;
+ case VFrame::SCREEN:
command->frame->to_texture();
- draw_output(command);
- break;
+ window->enable_opengl();
// Composite texture to screen and swap buffer
case VFrame::TEXTURE:
- draw_output(command);
- break;
- case VFrame::SCREEN:
-// swap buffers only
- window->flip_opengl();
+ draw_output(command, flip_y);
break;
default:
printf("Playback3D::write_buffer_sync unknown state\n");
break;
}
+ command->frame->set_opengl_state(frame_state);
window->unlock_window();
}
-void Playback3D::draw_output(Playback3DCommand *command)
+void Playback3D::draw_output(Playback3DCommand *command, int flip_y)
{
#ifdef HAVE_GL
int texture_id = command->frame->get_texture_id();
command->frame->draw_texture(
command->in_x1, command->in_y1, command->in_x2, command->in_y2,
command->out_x1, command->out_y1, command->out_x2, command->out_y2,
- 1);
+ flip_y);
-// printf("Playback3D::draw_output 2 %f,%f %f,%f -> %f,%f %f,%f\n",
+//printf("Playback3D::draw_output 2 %f,%f %f,%f -> %f,%f %f,%f\n",
// command->in_x1,
// command->in_y1,
// command->in_x2,
//printf("Playback3D::overlay_sync 1 %d\n", command->input->get_opengl_state());
- switch(command->input->get_opengl_state()) {
+ switch( command->input->get_opengl_state() ) {
// Upload texture and composite to screen
case VFrame::RAM:
command->input->to_texture();
// Convert colormodel to RGB if not nested.
// The color model setting in the output frame is ignored.
- if( command->is_nested <= 0 && // not nested
- BC_CModels::is_yuv(command->input->get_color_model()) ) {
- need_matrix = 1;
- shader_stack[total_shaders++] = yuv_to_rgb_frag;
- }
+// if( command->is_nested <= 0 && // not nested
+// BC_CModels::is_yuv(command->input->get_color_model()) ) {
+// need_matrix = 1;
+// shader_stack[total_shaders++] = yuv_to_rgb_frag;
+// }
// get the shaders
#define add_shader(s) \
}
// if to flatten alpha
- if( command->is_nested < 0 ) {
- switch(command->input->get_color_model()) {
-// yuv has already been converted to rgb
- case BC_YUVA8888:
- case BC_RGBA_FLOAT:
- case BC_RGBA8888:
- add_shader(rgba_to_rgb_flatten);
- break;
- }
- }
+// if( command->is_nested < 0 ) {
+// switch(command->input->get_color_model()) {
+//// yuv has already been converted to rgb
+// case BC_YUVA8888:
+// case BC_RGBA_FLOAT:
+// case BC_RGBA8888:
+// add_shader(rgba_to_rgb_flatten);
+// break;
+// }
+// }
// run the shaders
add_shader(0);
glUseProgram(0);
-// printf("Playback3D::overlay_sync %f %f %f %f %f %f %f %f\n",
+//printf("Playback3D::overlay_sync %f %f %f %f %f %f %f %f\n",
// command->in_x1, command->in_y1, command->in_x2, command->in_y2,
// command->out_x1, command->out_y1, command->out_x2, command->out_y2);
command->input->draw_texture(
command->in_x1, command->in_y1, command->in_x2, command->in_y2,
command->out_x1, command->out_y1, command->out_x2, command->out_y2,
-// Don't flip vertical if nested
- command->is_nested > 0 ? 0 : 1);
+ !command->is_nested);
glUseProgram(0);
// Delete temp texture