diff --git a/documentation/src/opengl.dox b/documentation/src/opengl.dox index c1ce8a9fd..0e538a13a 100644 --- a/documentation/src/opengl.dox +++ b/documentation/src/opengl.dox @@ -155,7 +155,7 @@ OpenGL window. HighDPI displays (including the so-called 'retina' displays of Apple hardware) are supported by FLTK in such a way that 1 unit of an FLTK quantity (say, the value given by Fl_Gl_Window::w()) corresponds to more -than 1 pixel on the display. Conversely, when a program specifies the width and height of the +than 1 pixel on the display. Consequently, when a program specifies the width and height of the OpenGL viewport, it is necessary to use an API that returns quantities expressed in pixels. That can be done as follows: \code @@ -164,9 +164,13 @@ That can be done as follows: \endcode which makes use of the Fl_Gl_Window::pixel_w() and Fl_Gl_Window::pixel_h() methods giving the size in pixels of an Fl_Gl_Window that is potentially mapped to a HighDPI display. -Method Fl_Gl_Window::pixels_per_unit() can also be useful in this context. -\note A further coding rule is necessary to properly support retina displays -and OpenGL under macOS (see \ref osissues_retina) + +Method Fl_Gl_Window::pixels_per_unit() can be useful when the OpenGL code depends on +the pixel dimension of the GL scene. This occurs, e.g., if a window's handle() method +uses Fl::event_x() and Fl::event_y() whose returned values should be multiplied by +Fl_Gl_Window::pixels_per_unit() to obtain the adequate pixel units. +This method may also be useful, for example, to adjust the width of a line in a +high resolution GL scene. \section opengl_normal Using OpenGL in Normal FLTK Windows diff --git a/documentation/src/osissues.dox b/documentation/src/osissues.dox index ce8a7fa74..d7d8fc030 100644 --- a/documentation/src/osissues.dox +++ b/documentation/src/osissues.dox @@ -931,34 +931,6 @@ Set "Print Front Window" = ""; therein so the application menu doesn't To localize the application name itself, create a file InfoPlist.strings in each .lproj directory and put CFBundleName = "localized name"; in each such file. -\subsection osissues_retina OpenGL and 'retina' displays -It is possible to have OpenGL produce graphics at the high pixel resolution allowed by the so-called 'retina' displays -present on recent Apple hardware. -For this, call -\verbatim -Fl::use_high_res_GL(1); -\endverbatim -before any Fl_Gl_Window is shown. Also, adapt your Fl_Gl_Window::draw() and Fl_Gl_Window::draw_overlay() methods replacing -\verbatim -glViewport(0, 0, w(), h()); -\endverbatim -by -\verbatim -glViewport(0, 0, pixel_w(), pixel_h()); -\endverbatim -making use of the Fl_Gl_Window::pixel_w() and Fl_Gl_Window::pixel_h() methods that return the width and height of -the GL scene in pixels: if the Fl_Gl_Window is mapped on a retina display, these methods return twice as much as -reported by Fl_Widget::w() and Fl_Widget::h(); if it's mapped on a regular display, they return the same values -as w() and h(). These methods dynamically change their values if the window is moved into/out from a retina -display. If Fl::use_high_res_GL(1) is not called, all Fl_Gl_Window 's are drawn at low resolution. -These methods are useful on all platforms because Fl_Gl_Window::w() and Fl_Gl_Window::h() don't return, -on HighDPI displays, the quantitites in pixels necessary to OpenGL functions . - -The Fl_Gl_Window::pixels_per_unit() method is useful when the OpenGL code depends on the pixel dimension -of the GL scene. This occurs, e.g., if a window's handle() method uses Fl::event_x() and Fl::event_y() -whose returned values should be multiplied by Fl_Gl_Window::pixels_per_unit() to obtain the adequate pixel units. -This method may also be useful, for example, to adjust the width of a line in a high resolution GL scene. - \subsection double_window Fl_Double_Window OS X double-buffers all windows automatically. On OS X, Fl_Window and Fl_Double_Window are handled diff --git a/examples/OpenGL3-glut-test.cxx b/examples/OpenGL3-glut-test.cxx index 8693b3861..1c3371999 100644 --- a/examples/OpenGL3-glut-test.cxx +++ b/examples/OpenGL3-glut-test.cxx @@ -192,7 +192,6 @@ int fullscreen = 0; int main (int argc, char* argv[]) { - Fl::use_high_res_GL(true); glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | FL_OPENGL3); glutInitWindowSize(400, 400); diff --git a/examples/OpenGL3test.cxx b/examples/OpenGL3test.cxx index c9f0d59e5..c65e9eb8b 100644 --- a/examples/OpenGL3test.cxx +++ b/examples/OpenGL3test.cxx @@ -250,7 +250,6 @@ void add_widgets(Fl_Gl_Window *g) { int main(int argc, char **argv) { - Fl::use_high_res_GL(1); Fl_Window *topwin = new Fl_Window(800, 300); SimpleGL3Window *win = new SimpleGL3Window(0, 0, 300, 300); win->end(); diff --git a/src/Fl.cxx b/src/Fl.cxx index 894897419..2cf5a41b0 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -2258,20 +2258,22 @@ Fl_Widget_Tracker::~Fl_Widget_Tracker() Fl::release_widget_pointer(wp_); // remove pointer from watch list } -int Fl::Private::use_high_res_GL_ = 0; +int Fl::Private::use_high_res_GL_ = 1; // default value changed beginning FLTK 1.5 -/** sets whether GL windows should be drawn at high resolution on Apple - computers with retina displays - \version 1.3.4 +/** Sets whether GL windows should be drawn at high resolution on Apple + computers with retina displays. + Because the default value is \c 1, this function is useful only in the very unlikely situation where a macOS app + would choose to draw low resolution GL graphics when mapped on a retina display. + This function has effect only under macOS. + \version 1.3.4 (default value changed in 1.5) */ void Fl::use_high_res_GL(int val) { Private::use_high_res_GL_ = val; } -/** returns whether GL windows should be drawn at high resolution on Apple +/** Returns whether GL windows should be drawn at high resolution on Apple computers with retina displays. - Default is no. - \version 1.3.4 + \version Default value set to 1 starting with FLTK 1.5 */ int Fl::use_high_res_GL() { return Private::use_high_res_GL_; diff --git a/test/CubeView.cxx b/test/CubeView.cxx index f2890d569..e2dc3f2a4 100644 --- a/test/CubeView.cxx +++ b/test/CubeView.cxx @@ -31,7 +31,6 @@ CubeView::CubeView(int x, int y, int w, int h, const char *l) : Fl_Box(x, y, w, h, l) #endif /* HAVE_GL */ { - Fl::use_high_res_GL(1); vAng = 0.0; hAng = 0.0; size = 10.0; diff --git a/test/cube.cxx b/test/cube.cxx index 609922762..69fb3ed88 100644 --- a/test/cube.cxx +++ b/test/cube.cxx @@ -388,7 +388,6 @@ void makeform(const char *name) { } int main(int argc, char **argv) { - Fl::use_high_res_GL(1); Fl::set_color(FL_FREE_COLOR, 255, 255, 0, 75); makeform(argv[0]); diff --git a/test/fractals.cxx b/test/fractals.cxx index 5e3839d03..af7aab9e9 100644 --- a/test/fractals.cxx +++ b/test/fractals.cxx @@ -767,7 +767,6 @@ void handlemenu(Fl_Widget*, void *value) {handlemenu(fl_int(value));} int main(int argc, char** argv) { - Fl::use_high_res_GL(1); // glutInit(&argc, argv); // this line removed for FLTK // create FLTK window: diff --git a/test/fullscreen.cxx b/test/fullscreen.cxx index 56432859e..ea1fcd28c 100644 --- a/test/fullscreen.cxx +++ b/test/fullscreen.cxx @@ -281,7 +281,6 @@ int arg(int, char **argv, int &i) { int main(int argc, char **argv) { - Fl::use_high_res_GL(1); int i=0; if (Fl::args(argc,argv,i,arg) < argc) Fl::fatal("Options are:\n -2 = 2 windows\n -f = startup fullscreen\n%s",Fl::help); diff --git a/test/gl_image.cxx b/test/gl_image.cxx index 3f64846e1..d877a6641 100644 --- a/test/gl_image.cxx +++ b/test/gl_image.cxx @@ -105,7 +105,6 @@ void chooser_cb(Fl_Widget *, Gl_Image_Window *mainwin) { int main(int argc, char **argv) { - Fl::use_high_res_GL(1); fl_register_images(); Gl_Image_Window mainwin(600, 600, "GL Image Viewer"); mainwin.show(argc, argv); diff --git a/test/gl_overlay.cxx b/test/gl_overlay.cxx index 3d46377bc..958aa3fe3 100644 --- a/test/gl_overlay.cxx +++ b/test/gl_overlay.cxx @@ -106,7 +106,6 @@ void overlay_sides_cb(Fl_Widget *o, void *p) { #include int main(int argc, char **argv) { - Fl::use_high_res_GL(1); Fl_Window window(300, 370); shape_window sw(10, 75, window.w()-20, window.h()-90); diff --git a/test/glpuzzle.cxx b/test/glpuzzle.cxx index a05c26535..9489253be 100644 --- a/test/glpuzzle.cxx +++ b/test/glpuzzle.cxx @@ -1449,7 +1449,6 @@ main(int argc, char **argv) { long i; - Fl::use_high_res_GL(1); glutInit(&argc, argv); for (i = 1; i < argc; i++) { if (argv[i][0] == '-') { diff --git a/test/shape.cxx b/test/shape.cxx index 962e66473..8d58e1f45 100644 --- a/test/shape.cxx +++ b/test/shape.cxx @@ -79,7 +79,6 @@ void sides_cb(Fl_Widget *o, void *p) { int main(int argc, char **argv) { - Fl::use_high_res_GL(1); Fl_Window window(300, 330); // the shape window could be it's own window, but here we make it diff --git a/test/unittests.cxx b/test/unittests.cxx index 7d537cc75..ceb3ba18e 100644 --- a/test/unittests.cxx +++ b/test/unittests.cxx @@ -450,7 +450,6 @@ int main(int argc, char** argv) { Fl::get_system_colors(); Fl::scheme(Fl::scheme()); // init scheme before instantiating tests Fl::visual(FL_RGB); - Fl::use_high_res_GL(1); mainwin = new Ut_Main_Window(UT_MAINWIN_W, UT_MAINWIN_H, "FLTK Unit Tests"); mainwin->size_range(UT_MAINWIN_W, UT_MAINWIN_H); browser = new Fl_Hold_Browser(UT_BROWSER_X, UT_BROWSER_Y, UT_BROWSER_W, UT_BROWSER_H, "Unit Tests");