[fltk/fltk] fl_rescale_offscreen weird behavior on windows (Issue #475)
Mohammed Alyousef
Aug 01, 2022
Hi
Not sure if it's because I'm not using it correctly, but this example works correctly on Linux and macOS:
#include<FL/Fl.H>
#include<FL/Enumerations.H>
#include<FL/Fl_Box.H>
#include<FL/Fl_Double_Window.H>
#include<FL/fl_draw.H>classCanvas : publicFl_Box {
Fl_Offscreen offs = 0;
int ox = 0, oy = 0;
public:Canvas(int x, int y, int w, int h)
: Fl_Box(x, y, w, h), offs(fl_create_offscreen(w, h)) {
fl_begin_offscreen(offs);
fl_color(FL_WHITE);
fl_rectf(0, 0, w, h);
fl_end_offscreen();
}
voiddraw() override {
if (offs) {
fl_rescale_offscreen(offs);
fl_copy_offscreen(x(), y(), w(), h(), offs, 0, 0);
}
Fl_Box::draw();
}
inthandle(int e) override {
auto ret = Fl_Box::handle(e);
switch (e) {
case FL_PUSH: {
fl_begin_offscreen(offs);
fl_color(FL_RED);
fl_line_style(FL_SOLID, 3);
ox = Fl::event_x();
oy = Fl::event_y();
fl_point(ox, oy);
fl_end_offscreen();
redraw();
fl_line_style(FL_SOLID, 0);
returntrue;
}
case FL_DRAG: {
fl_begin_offscreen(offs);
fl_color(FL_RED);
fl_line_style(FL_SOLID, 3);
int nx = Fl::event_x();
int ny = Fl::event_y();
fl_line(ox, oy, nx, ny);
ox = nx;
oy = ny;
fl_end_offscreen();
redraw();
fl_line_style(FL_SOLID, 0);
returntrue;
}
default:
return ret;
}
}
};
intmain() {
auto win = newFl_Window(800, 600);
auto box = newCanvas(5, 5, 790, 590);
win->end();
win->show();
returnFl::run();
}
If you remove the call to fl_rescale_offscreen, it works correctly, but the call is necessary if resizing is needed.
This produces a strange artifcat while drawing:
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: <fltk/fltk/issues/475@github.com>
Comments are owned by the poster. All other content is copyright 1998-2025 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.