add disable opengl masking, switch shift/ctrl op in mask gui
authorGood Guy <good1.2guy@gmail.com>
Tue, 5 Apr 2016 14:34:01 +0000 (08:34 -0600)
committerGood Guy <good1.2guy@gmail.com>
Tue, 5 Apr 2016 14:34:01 +0000 (08:34 -0600)
16 files changed:
cinelerra-5.1/cinelerra/cwindowgui.C
cinelerra-5.1/cinelerra/cwindowtool.C
cinelerra-5.1/cinelerra/cwindowtool.h
cinelerra-5.1/cinelerra/maskauto.C
cinelerra-5.1/cinelerra/maskauto.h
cinelerra-5.1/cinelerra/mwindowgui.C
cinelerra-5.1/cinelerra/pluginclient.C
cinelerra-5.1/cinelerra/preferences.C
cinelerra-5.1/cinelerra/preferencesthread.C
cinelerra-5.1/cinelerra/vdevicex11.C
cinelerra-5.1/cinelerra/vdevicex11.h
cinelerra-5.1/cinelerra/virtualvnode.C
cinelerra-5.1/cinelerra/vmodule.C
cinelerra-5.1/guicast/bctexture.C
cinelerra-5.1/guicast/bctexture.h
cinelerra-5.1/guicast/vframe3d.C

index 13a1ca763a7281d4bbb1246020bb345b7aa0a43b..73c11dc5cca985735f44b0239af095aba5f2a2d4 100644 (file)
@@ -1381,6 +1381,7 @@ static inline bool test_bbox(int cx, int cy, int tx, int ty)
        return (llabs(cx-tx) < CONTROL_W/2 && llabs(cy-ty) < CONTROL_H/2);
 }
 
+
 int CWindowCanvas::do_mask(int &redraw, int &rerender,
                int button_press, int cursor_motion, int draw)
 {
@@ -1567,7 +1568,7 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                        float canvas_x = (x0 - half_track_w) * projector_z + projector_x;
                                        float canvas_y = (y0 - half_track_h) * projector_z + projector_y;
 // Test first point
-                                       if(gui->shift_down()) {
+                                       if(gui->ctrl_down()) {
                                                float control_x = (x1 - half_track_w) * projector_z + projector_x;
                                                float control_y = (y1 - half_track_h) * projector_z + projector_y;
                                                float distance = line_dist(control_x,control_y, mask_cursor_x,mask_cursor_y);
@@ -1579,7 +1580,7 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                                }
                                        }
                                        else {
-                                               if(!gui->ctrl_down()) {
+                                               if(!gui->shift_down()) {
                                                        if(test_bbox(cursor_x, cursor_y, canvas_x, canvas_y)) {
                                                                selected_point = i;
                                                        }
@@ -1592,7 +1593,7 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                        canvas_x = (x3 - half_track_w) * projector_z + projector_x;
                                        canvas_y = (y3 - half_track_h) * projector_z + projector_y;
 
-                                       if(gui->shift_down()) {
+                                       if(gui->ctrl_down()) {
                                                float control_x = (x2 - half_track_w) * projector_z + projector_x;
                                                float control_y = (y2 - half_track_h) * projector_z + projector_y;
                                                float distance = line_dist(control_x,control_y, mask_cursor_x,mask_cursor_y);
@@ -1605,7 +1606,7 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                                }
                                        }
                                        else if(i < points.size() - 1) {
-                                               if(!gui->ctrl_down()) {
+                                               if(!gui->shift_down()) {
                                                        if(test_bbox(cursor_x, cursor_y, canvas_x, canvas_y)) {
                                                                selected_point = (i < points.size() - 1 ? i + 1 : 0);
                                                        }
@@ -1747,7 +1748,7 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                gui->current_operation = mwindow->edl->session->cwindow_operation;
                }
                else // No existing point or control point was selected so create a new one
-               if(!gui->shift_down() && !gui->alt_down()) {
+               if(!gui->ctrl_down() && !gui->alt_down()) {
                        mwindow->undo->update_undo_before(_("mask point"), 0);
 // Create the template
                        MaskPoint *point = new MaskPoint;
@@ -2013,7 +2014,7 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                        over_point = 1;
                                }
 
-                               if(!over_point && gui->shift_down()) {
+                               if(!over_point && gui->ctrl_down()) {
                                        canvas_x = (x1 - half_track_w) * projector_z + projector_x;
                                        canvas_y = (y1 - half_track_h) * projector_z + projector_y;
                                        output_to_canvas(mwindow->edl, 0, canvas_x, canvas_y);
@@ -2058,7 +2059,6 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
        return result;
 }
 
-
 int CWindowCanvas::do_eyedrop(int &rerender, int button_press, int draw)
 {
        int result = 0;
index 64c9f4f38710e0305a63ed991828a71a695d285c..6a4a1d7255deaec89758e6729d6e45e94738dbe7 100644 (file)
@@ -457,10 +457,6 @@ void CWindowCropGUI::update()
 }
 
 
-
-
-
-
 CWindowEyedropGUI::CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread)
  : CWindowToolGUI(mwindow,
        thread,
@@ -675,10 +671,6 @@ int CWindowCurveToggle::handle_event()
 }
 
 
-
-
-
-
 CWindowCameraGUI::CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread)
  : CWindowToolGUI(mwindow,
        thread,
@@ -1120,21 +1112,6 @@ int CWindowCameraBottom::handle_event()
 }
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
  : CWindowToolGUI(mwindow,
        thread,
@@ -1330,44 +1307,6 @@ void CWindowProjectorGUI::update()
        }
 }
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
  : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
 {
@@ -1576,12 +1515,6 @@ int CWindowProjectorBottom::handle_event()
 }
 
 
-
-
-
-
-
-
 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
        CWindowToolGUI *gui, int x, int y, const char *text)
  : BC_PopupMenu(x, y, 220, text, 1)
@@ -2046,6 +1979,30 @@ int CWindowMaskBeforePlugins::handle_event()
 }
 
 
+CWindowDisableOpenGLMasking::CWindowDisableOpenGLMasking(CWindowToolGUI *gui, int x, int y)
+ : BC_CheckBox(x, y, 1, _("Disable OpenGL masking"))
+{
+       this->gui = gui;
+}
+
+int CWindowDisableOpenGLMasking::handle_event()
+{
+       Track *track;
+       MaskAutos *autos;
+       MaskAuto *keyframe;
+       SubMask *mask;
+       MaskPoint *point;
+       ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
+
+       if (keyframe) {
+               keyframe->disable_opengl_masking = get_value();
+               gui->update_preview();
+       }
+       return 1;
+}
+
+
+
 
 
 
@@ -2057,7 +2014,7 @@ CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
        thread,
        _(PROGRAM_NAME ": Mask"),
        330,
-       280)
+       310)
 {
        this->mwindow = mwindow;
        this->thread = thread;
@@ -2121,19 +2078,16 @@ void CWindowMaskGUI::create_objects()
 
        x = 10;
        y += this->y->get_h() + margin;
-       add_subwindow(title = new BC_Title(x, y, _("Press Ctrl to move a point")));
+       add_subwindow(title = new BC_Title(x, y, _("Press Shift to move an end point")));
        y += title->get_h() + margin;
-       add_subwindow(title = new BC_Title(x, y, _("Press Alt to translate the mask")));
+       add_subwindow(title = new BC_Title(x, y, _("Press Ctrl to move a control point")));
        y += title->get_h() + margin;
-       add_subwindow(title = new BC_Title(x, y, _("Press Shift to edit bezier curve")));
-
+       add_subwindow(title = new BC_Title(x, y, _("Press Alt to translate the mask")));
        y += 30;
-//     add_subwindow(title = new BC_Title(x, y, _("Apply mask before plugins:")));
 
-       add_subwindow(this->apply_before_plugins = new CWindowMaskBeforePlugins(this,
-               10,
-               y));
-//     this->apply_before_plugins->create_objects();
+       add_subwindow(this->apply_before_plugins = new CWindowMaskBeforePlugins(this, 10, y));
+       y += this->apply_before_plugins->get_h() + margin;
+       add_subwindow(this->disable_opengl_masking = new CWindowDisableOpenGLMasking(this, 10, y));
 
        update();
        unlock_window();
@@ -2201,6 +2155,7 @@ void CWindowMaskGUI::update()
                        feather->update((int64_t)autos->get_feather(position_i, PLAY_FORWARD));
                        value->update((int64_t)autos->get_value(position_i, PLAY_FORWARD));
                        apply_before_plugins->update((int64_t)keyframe->apply_before_plugins);
+                       disable_opengl_masking->update((int64_t)keyframe->disable_opengl_masking);
                }
        }
 
index 2242b2bcc1b5a1b51d722d36230db2f7c2ab3795..2fb3ab9ff63891ce1c6f90909015b3341601964c 100644 (file)
@@ -218,8 +218,13 @@ public:
        CWindowToolGUI *gui;
 };
 
-
-
+class CWindowDisableOpenGLMasking : public BC_CheckBox
+{
+public:
+       CWindowDisableOpenGLMasking(CWindowToolGUI *gui, int x, int y);
+       int handle_event();
+       CWindowToolGUI *gui;
+};
 
 class CWindowMaskGUI : public CWindowToolGUI
 {
@@ -244,6 +249,7 @@ public:
        CWindowMaskNumber *number;
        CWindowMaskValue *value;
        CWindowMaskBeforePlugins *apply_before_plugins;
+       CWindowDisableOpenGLMasking *disable_opengl_masking;
 };
 
 
index d5beae3bee2315915e50ab4813704bf145075eb3..b9681418f5297dbac53f575718f44549a21382c3 100644 (file)
@@ -224,6 +224,7 @@ MaskAuto::MaskAuto(EDL *edl, MaskAutos *autos)
        feather = 0;
        value = 100;
        apply_before_plugins = 0;
+       disable_opengl_masking = 0;
 
 // We define a fixed number of submasks so that interpolation for each
 // submask matches.
@@ -256,7 +257,8 @@ int MaskAuto::identical(MaskAuto *src)
                mode != src->mode ||
                feather != src->feather ||
                masks.size() != src->masks.size() ||
-               apply_before_plugins != src->apply_before_plugins) return 0;
+               apply_before_plugins != src->apply_before_plugins ||
+               disable_opengl_masking != src->disable_opengl_masking) return 0;
 
        for(int i = 0; i < masks.size(); i++)
                if(!(*masks.values[i] == *src->masks.values[i])) return 0;
@@ -305,6 +307,7 @@ void MaskAuto::copy_data(MaskAuto *src)
        feather = src->feather;
        value = src->value;
        apply_before_plugins = src->apply_before_plugins;
+       disable_opengl_masking = src->disable_opengl_masking;
 
        masks.remove_all_objects();
        for(int i = 0; i < src->masks.size(); i++)
@@ -329,6 +332,7 @@ int MaskAuto::interpolate_from(Auto *a1, Auto *a2, int64_t position, Auto *templ
        this->feather = mask_auto1->feather;
        this->value = mask_auto1->value;
        this->apply_before_plugins = mask_auto1->apply_before_plugins;
+       this->disable_opengl_masking = mask_auto1->disable_opengl_masking;
        this->position = position;
        masks.remove_all_objects();
 
@@ -400,6 +404,7 @@ void MaskAuto::load(FileXML *file)
        feather = file->tag.get_property("FEATHER", feather);
        value = file->tag.get_property("VALUE", value);
        apply_before_plugins = file->tag.get_property("APPLY_BEFORE_PLUGINS", apply_before_plugins);
+       disable_opengl_masking = file->tag.get_property("DISABLE_OPENGL_MASKING", disable_opengl_masking);
        for(int i = 0; i < masks.size(); i++)
        {
                delete masks.values[i];
@@ -433,6 +438,7 @@ void MaskAuto::copy(int64_t start, int64_t end, FileXML *file, int default_auto)
        file->tag.set_property("VALUE", value);
        file->tag.set_property("FEATHER", feather);
        file->tag.set_property("APPLY_BEFORE_PLUGINS", apply_before_plugins);
+       file->tag.set_property("DISABLE_OPENGL_MASKING", disable_opengl_masking);
 
        if(default_auto)
                file->tag.set_property("POSITION", 0);
index 4b8b9562a1a938db5fac5e0e06ab6f39d2d92eca..5162d8e97d6fef901b478daeabc96c5bffad65fa 100644 (file)
@@ -102,6 +102,7 @@ public:
 // 0 - 100
        int value;
        int apply_before_plugins;
+       int disable_opengl_masking;
 };
 
 
index 23fa22a2f1e48b0385070a17bb44c97a82d9222a..418146626e87d3da17cc405497531c9ab821fb09 100644 (file)
@@ -2389,7 +2389,8 @@ FFMpegToggle::FFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
 {
        this->mwindow = mwindow;
        this->mbuttons = mbuttons;
-       set_tooltip(_("FFMpeg early probe"));
+       set_tooltip( mwindow->preferences->ffmpeg_early_probe ?
+               _("Try FFMpeg first") : _("Try FFMpeg last"));
 }
 
 FFMpegToggle::~FFMpegToggle()
@@ -2399,6 +2400,8 @@ FFMpegToggle::~FFMpegToggle()
 int FFMpegToggle::handle_event()
 {
        mwindow->preferences->ffmpeg_early_probe = get_value();
+       set_tooltip( mwindow->preferences->ffmpeg_early_probe ?
+               _("Try FFMpeg first") : _("Try FFMpeg last"));
        mwindow->show_warning(&mwindow->preferences->warn_indexes,
                _("Changing the base codecs may require rebuilding indexes."));
        return 1;
index c401ef22dd19634f00196342d573505251256491..cccdcde077d8bc6bfefe9c021b2b1b9f99a4dc02 100644 (file)
@@ -592,23 +592,21 @@ void PluginClient::save_defaults_xml()
        using_defaults = 1;
 
        KeyFrame temp_keyframe;
-
        save_data(&temp_keyframe);
-       FILE *fd = fopen(path, "w");
-       if(fd)
-       {
-               fprintf(fd, "%d\n%d\n", window_x, window_y);
-               if(!fwrite(temp_keyframe.get_data(), strlen(temp_keyframe.get_data()), 1, fd))
-               {
+
+       const char *data = temp_keyframe.get_data();
+       int len = strlen(data);
+       FILE *fp = fopen(path, "w");
+
+       if( fp ) {
+               fprintf(fp, "%d\n%d\n", window_x, window_y);
+               if( len > 0 && !fwrite(data, len, 1, fp) ) {
                        fprintf(stderr, "PluginClient::save_defaults_xml %d \"%s\" %d bytes: %s\n",
-                               __LINE__,
-                               path,
-                               (int)strlen(temp_keyframe.get_data()),
-                               strerror(errno));
+                               __LINE__, path, len, strerror(errno));
                }
-
-               fclose(fd);
+               fclose(fp);
        }
+
        using_defaults = 0;
 }
 
index 5d4692204ed20922388c7dffbb36867778020301..0eca68eb76919e43390d05f09904159a449efc16 100644 (file)
@@ -372,8 +372,8 @@ int Preferences::load_defaults(BC_Hash *defaults)
        shbtn_prefs.remove_all_objects();
        int shbtns_total = defaults->get("SHBTNS_TOTAL", -1);
        if( shbtns_total < 0 ) {
-               shbtn_prefs.append(new ShBtnPref("manual", "firefox file:///$CINELERRA_PATH/manual.pdf", 0));
-               shbtn_prefs.append(new ShBtnPref("online help", "firefox http://cinelerra.org/help.php/", 0));
+//             shbtn_prefs.append(new ShBtnPref("manual", "firefox file:///$CINELERRA_PATH/manual.pdf", 0));
+               shbtn_prefs.append(new ShBtnPref("online help", "firefox https://cinelerra-cv.org/docs/cinelerra_cv_manual_en.html", 0));
                shbtns_total = 0;
        }
        for( int i=0; i<shbtns_total; ++i ) {
index 2ee2e2cb4343cb62170ac35c9dc06871c7841e47..10af4ffbd2020901a2807209709cb094ebb3265a 100644 (file)
@@ -214,6 +214,8 @@ int PreferencesThread::apply_settings()
 
        mwindow->reset_android_remote();
        mwindow->gui->ffmpeg_toggle->update(mwindow->preferences->ffmpeg_early_probe);
+       mwindow->gui->ffmpeg_toggle->set_tooltip( mwindow->preferences->ffmpeg_early_probe ?
+               _("Try FFMpeg first") : _("Try FFMpeg last") );
        mwindow->gui->mainshbtns->load(mwindow->preferences);
        double tc_position = 
                mwindow->edl->session->get_frame_offset() / mwindow->edl->session->frame_rate;
index e1b5c2a91dbc0112ce2f1a714be9b8816a265517..5d07807d51cfa63f339513c1f7a908be8c69984f 100644 (file)
  */
 
 #include "assets.h"
+#include "auto.h"
 #include "bccapture.h"
 #include "bcsignals.h"
 #include "canvas.h"
 #include "bccmodels.h"
 #include "edl.h"
 #include "edlsession.h"
+#include "maskautos.h"
+#include "maskauto.h"
 #include "mwindow.h"
 #include "playback3d.h"
 #include "playbackconfig.h"
@@ -678,9 +681,17 @@ void VDeviceX11::do_fade(VFrame *output_temp, float fade)
        this->output->mwindow->playback_3d->do_fade(this->output, output_temp, fade);
 }
 
-void VDeviceX11::do_mask(VFrame *output_temp, int64_t start_position_project,
-               MaskAutos *keyframe_set, MaskAuto *keyframe,
-               MaskAuto *default_auto)
+bool VDeviceX11::can_mask(int64_t start_position_project, MaskAutos *keyframe_set)
+{
+       Auto *current = 0;
+       MaskAuto *keyframe = (MaskAuto*)keyframe_set->
+               get_prev_auto(start_position_project, PLAY_FORWARD, current);
+       return keyframe->disable_opengl_masking ? 0 : 1;
+}
+
+void VDeviceX11::do_mask(VFrame *output_temp,
+       int64_t start_position_project, MaskAutos *keyframe_set,
+       MaskAuto *keyframe, MaskAuto *default_auto)
 {
        this->output->mwindow->playback_3d->do_mask(output,
                output_temp, start_position_project,
index 6bfb8ac17bcaecad163f1354b3b4231561449786..f8af6916d3dca00526b7dbf5d71e2c3fafc921b5 100644 (file)
@@ -82,11 +82,10 @@ public:
        void do_fade(VFrame *output_temp, float fade);
 
 // Hardware version of MaskEngine
-       void do_mask(VFrame *output_temp, 
-               int64_t start_position_project,
-               MaskAutos *keyframe_set, 
-               MaskAuto *keyframe,
-               MaskAuto *default_auto);
+       bool can_mask(int64_t start_position_project, MaskAutos *keyframe_set);
+       void do_mask(VFrame *output, 
+               int64_t start_position_project, MaskAutos *keyframe_set, 
+               MaskAuto *keyframe, MaskAuto *default_auto);
        void convert_cmodel(VFrame *output, int dst_cmodel);
 
 // The idea is to composite directly in the frame buffer if OpenGL.
index 1fb4846140f52c4fdc14393dbbe6f1ab2173f8f4..27c65bba868c84319be7c0711536103cd90c757c 100644 (file)
@@ -353,17 +353,21 @@ void VirtualVNode::render_mask(VFrame *output_temp,
                return;
        }
 
-       if(use_opengl)
-       {
+       if(use_opengl) {
+               if( !((VDeviceX11*)((VirtualVConsole*)vconsole)->get_vdriver())->can_mask(
+                               start_position_project, keyframe_set) )
+                       use_opengl = 0;
+                       
+       }
+       if(use_opengl) {
                ((VDeviceX11*)((VirtualVConsole*)vconsole)->get_vdriver())->do_mask(
-                       output_temp, start_position_project,
-                       keyframe_set, keyframe, keyframe);
+                               output_temp, start_position_project, keyframe_set,
+                               keyframe, keyframe);
        }
-       else
-       {
+       else {
 // Revert to software
                masker->do_mask(output_temp, start_position_project,
-                       keyframe_set, keyframe, keyframe);
+                               keyframe_set, keyframe, keyframe);
        }
 }
 
index 48f2643dafb6ecb42c1e1c488ebc12b04730d5bf..6d69dc3c454acad0f656caed4f423ecd79da85f2 100644 (file)
@@ -50,6 +50,7 @@
 #include "vedit.h"
 #include "vframe.h"
 #include "videodevice.h"
+#include "virtualvconsole.h"
 #include "vmodule.h"
 #include "vrender.h"
 #include "vplugin.h"
@@ -1083,21 +1084,34 @@ int VModule::render(VFrame *output,
                        use_opengl);
        }
 
-       int64_t mask_position = !renderengine ? start_position :
-               renderengine->vrender->current_position;
        Auto *current = 0;
        MaskAutos *keyframe_set =
                (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
-        MaskAuto *keyframe =
+       int64_t mask_position = !renderengine ? start_position :
+               renderengine->vrender->current_position;
+               MaskAuto *keyframe =
                (MaskAuto*)keyframe_set->get_prev_auto(mask_position, direction, current);
+
        if( keyframe->apply_before_plugins ) {
-               if( !masker ) {
-                       int cpus = renderengine ?
-                               renderengine->preferences->processors :
-                               plugin_array->mwindow->preferences->processors;
-                       masker = new MaskEngine(cpus);
+               VDeviceX11 *x11_device = 0;
+               if(use_opengl && renderengine && renderengine->video) {
+                       x11_device = (VDeviceX11*)renderengine->video->get_output_base();
+                       if( !x11_device->can_mask(mask_position, keyframe_set) )
+                               use_opengl = 0;
+               }
+               if( use_opengl && x11_device ) {
+                       x11_device->do_mask(output, mask_position, keyframe_set,
+                                       keyframe, keyframe);
+               }
+               else {
+                       if( !masker ) {
+                               int cpus = renderengine ?
+                                       renderengine->preferences->processors :
+                                       plugin_array->mwindow->preferences->processors;
+                               masker = new MaskEngine(cpus);
+                       }
+                       masker->do_mask(output, mask_position, keyframe_set, keyframe, keyframe);
                }
-               masker->do_mask(output, mask_position, keyframe_set, keyframe, keyframe);
        }
 
        return result;
index 1ecbfd35c856b9271b6ed6ce51e852b32a9185da..ef77f8ea35422cf07a5e7e06586518f89e098d34 100644 (file)
@@ -186,6 +186,21 @@ int BC_Texture::get_window_id()
 }
 
 
+void BC_Texture::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)
+{
+#ifdef HAVE_GL
+       glBegin(GL_QUADS);
+       glNormal3f(0, 0, 1.0);
+       glTexCoord2f(in_x1, in_y1);   glVertex3f(out_x1, out_y1, 0);
+       glTexCoord2f(in_x2, in_y1);   glVertex3f(out_x2, out_y1, 0);
+       glTexCoord2f(in_x2, in_y2);   glVertex3f(out_x2, out_y2, 0);
+       glTexCoord2f(in_x1, in_y2);   glVertex3f(out_x1, out_y2, 0);
+       glEnd();
+#endif
+}
+
 void BC_Texture::bind(int texture_unit)
 {
 #ifdef HAVE_GL
@@ -212,3 +227,18 @@ void BC_Texture::bind(int texture_unit)
 #endif
 }
 
+void write_ppm(uint8_t *tp, int w, int h, const char *fmt, ...);
+
+void BC_Texture::write_tex(const char *fn)
+{
+       int prev_id = -1;
+       glGetIntegerv(GL_ACTIVE_TEXTURE, &prev_id);
+       glActiveTexture(this->texture_id);
+       int w = get_texture_w(), h = get_texture_h();
+       uint8_t img[w*h*3];
+       glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, img);
+       write_ppm(img, w, h, "%s", fn);
+       glActiveTexture(prev_id);
+}
+
+
index 3063a5faad23e51956013c472d2460e7da6229bd..e0aa34852e4d6c6bdcab40e77582fc45058ba9ba 100644 (file)
@@ -62,7 +62,11 @@ public:
        int get_texture_h();
        int get_texture_components();
        int get_window_id();
+       void 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);
 
+       void write_tex(const char *fn);
 private:
        void clear_objects();
 
index f6f0a440cf85fdf41364655287d660387e73465a..7b7d170e0a098921800cdabbe9cec66a1ae10c46 100644 (file)
@@ -229,49 +229,26 @@ void VFrame::screen_to_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)
+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
-       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();
-
+       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);
 }