rework index builder, add pro ffmpeg format
[goodguy/history.git] / cinelerra-5.1 / guicast / vframe3d.C
index 3ed62aca30548e2da45e096ed7649e7ffc6c8107..7b7d170e0a098921800cdabbe9cec66a1ae10c46 100644 (file)
@@ -152,33 +152,6 @@ void VFrame::to_texture()
 #endif
 }
 
-void VFrame::to_ram()
-{
-#ifdef HAVE_GL
-       switch(opengl_state)
-       {
-// Only pbuffer is supported since this is only called after the
-// overlay operation onto the pbuffer.
-               case VFrame::SCREEN:
-                       if(pbuffer)
-                       {
-                               enable_opengl();
-//printf("VFrame::to_ram %d %d\n", get_w(), get_h());
-                               glReadPixels(0,
-                                       0,
-                                       get_w(),
-                                       get_h(),
-                                       GL_RGB,
-                                       GL_UNSIGNED_BYTE,
-                                       get_rows()[0]);
-                               flip_vert();
-                       }
-                       opengl_state = VFrame::RAM;
-                       return;
-       }
-#endif
-}
-
 void VFrame::create_pbuffer()
 {
        if(pbuffer &&
@@ -220,12 +193,9 @@ void VFrame::screen_to_texture(int x, int y, int w, int h)
 #ifdef HAVE_GL
 // Create texture
        BC_Texture::new_texture(&texture,
-               get_w(),
-               get_h(),
-               get_color_model());
+               get_w(), get_h(), get_color_model());
 
-       if(pbuffer)
-       {
+       if(pbuffer) {
                glEnable(GL_TEXTURE_2D);
 
 // Read canvas into texture, use back texture for DOUBLE_BUFFER
@@ -247,49 +217,38 @@ void VFrame::screen_to_texture(int x, int y, int w, int h)
 #endif
 }
 
-void VFrame::draw_texture(float in_x1,
-               float in_y1,
-               float in_x2,
-               float in_y2,
-               float out_x1,
-               float out_y1,
-               float out_x2,
-               float out_y2,
-               int flip_y)
+void VFrame::screen_to_ram()
 {
 #ifdef HAVE_GL
-       glBegin(GL_QUADS);
-       glNormal3f(0, 0, 1.0);
-
-       glTexCoord2f(in_x1 / get_texture_w(), in_y1 / get_texture_h());
-       glVertex3f(out_x1, flip_y ? -out_y1 : -out_y2, 0);
-
-       glTexCoord2f(in_x2 / get_texture_w(), in_y1 / get_texture_h());
-       glVertex3f(out_x2, flip_y ? -out_y1 : -out_y2, 0);
-
-       glTexCoord2f(in_x2 / get_texture_w(), in_y2 / get_texture_h());
-       glVertex3f(out_x2, flip_y ? -out_y2 : -out_y1, 0);
-
-       glTexCoord2f(in_x1 / get_texture_w(), in_y2 / get_texture_h());
-       glVertex3f(out_x1, flip_y ? -out_y2 : -out_y1, 0);
-
-
-       glEnd();
+       enable_opengl();
+       glReadBuffer(GL_BACK);
+       int type = BC_CModels::is_float(color_model) ? GL_FLOAT : GL_UNSIGNED_BYTE;
+       int format = BC_CModels::has_alpha(color_model) ? GL_RGBA : GL_RGB;
+       glReadPixels(0, 0, get_w(), get_h(), format, type, get_rows()[0]);
+       opengl_state = VFrame::RAM;
+#endif
+}
 
+void VFrame::draw_texture(
+       float in_x1, float in_y1, float in_x2, float in_y2,
+       float out_x1, float out_y1, float out_x2, float out_y2,
+       int flip_y)
+{
+#ifdef HAVE_GL
+       in_x1 /= get_texture_w();  in_y1 /= get_texture_h();
+       in_x2 /= get_texture_w();  in_y2 /= get_texture_h();
+       float ot_y1 = flip_y ? -out_y1 : -out_y2;
+       float ot_y2 = flip_y ? -out_y2 : -out_y1;
+       texture->draw_texture(
+               in_x1,in_y1,  in_x2,in_y2,
+               out_x1,ot_y1, out_x2, ot_y2);
 #endif
 }
 
 void VFrame::draw_texture(int flip_y)
 {
-       draw_texture(0,
-               0,
-               get_w(),
-               get_h(),
-               0,
-               0,
-               get_w(),
-               get_h(),
-               flip_y);
+       draw_texture(0,0,  get_w(),get_h(),
+               0,0, get_w(),get_h(), flip_y);
 }