X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fplayback3d.C;h=9eee736f36d47d926bd6ca8909c03ec897c5ed52;hb=83b70dd60863377cb281e6be5206304e10373e30;hp=1844f808ef3aade81a87ecdf28f54049a4f01961;hpb=e620b69f6d3f1de30d8b2a16c46d7729462e5211;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/playback3d.C b/cinelerra-5.1/cinelerra/playback3d.C index 1844f808..9eee736f 100644 --- a/cinelerra-5.1/cinelerra/playback3d.C +++ b/cinelerra-5.1/cinelerra/playback3d.C @@ -509,63 +509,63 @@ void Playback3D::copy_from_sync(Playback3DCommand *command) if( window ) { window->enable_opengl(); glFinish(); + int copy_to_ram = 0; int w = command->input->get_w(); int h = command->input->get_h(); - - if(command->input->get_opengl_state() == VFrame::SCREEN && - w == command->frame->get_w() && h == command->frame->get_h()) - { + if( command->input->get_opengl_state() == VFrame::SCREEN && + w == command->frame->get_w() && h == command->frame->get_h() ) { // printf("Playback3D::copy_from_sync 1 %d %d %d %d %d\n", -// command->input->get_w(), -// command->input->get_h(), -// command->frame->get_w(), -// command->frame->get_h(), +// command->input->get_w(), command->input->get_h(), +// command->frame->get_w(), command->frame->get_h(), // command->frame->get_color_model()); #ifdef GLx4 // With NVidia at least - if(w % 4) - { + if(w % 4) { printf("Playback3D::copy_from_sync: w=%d not supported because it is not divisible by 4.\n", w); } else #endif // Copy to texture - if(command->want_texture) - { + if( command->want_texture ) { //printf("Playback3D::copy_from_sync 1 dst=%p src=%p\n", command->frame, command->input); // Screen_to_texture requires the source pbuffer enabled. command->input->enable_opengl(); command->frame->screen_to_texture(); command->frame->set_opengl_state(VFrame::TEXTURE); } - else -// Copy to RAM - { + else { 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); + copy_to_ram = 1; } } - else - { + else if( command->input->get_opengl_state() == VFrame::TEXTURE && + w == command->frame->get_w() && h == command->frame->get_h() ) { + copy_to_ram = 1; + } + else { printf("Playback3D::copy_from_sync: invalid formats opengl_state=%d %dx%d -> %dx%d\n", command->input->get_opengl_state(), w, h, command->frame->get_w(), command->frame->get_h()); } + + if( copy_to_ram ) { + 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); + } } command->canvas->unlock_canvas(); #endif @@ -728,7 +728,11 @@ void Playback3D::draw_output(Playback3DCommand *command, int flip_y) if(!command->is_cleared) { // If we get here, the virtual console was not used. - color_frame(command, 0,0,0,0); + int color = command->canvas->get_clear_color(); + int r = (color>>16) & 0xff; // always rgb + int g = (color>>8) & 0xff; + int b = (color>>0) & 0xff; + color_frame(command, r/255.f, g/255.f, b/255.f, 0.f); } // Texture @@ -802,11 +806,14 @@ void Playback3D::clear_output_sync(Playback3DCommand *command) // Using pbuffer for refresh frame. if( command->frame ) { command->frame->enable_opengl(); + command->frame->set_opengl_state(VFrame::SCREEN); color = command->frame->get_clear_color(); alpha = command->frame->get_clear_alpha(); int color_model = command->canvas->mwindow->edl->session->color_model; is_yuv = BC_CModels::is_yuv(color_model); } + else + color = command->canvas->get_clear_color(); int a = alpha; int r = (color>>16) & 0xff; int g = (color>>8) & 0xff;