mirror of
https://github.com/fltk/fltk.git
synced 2026-08-17 16:43:10 +08:00
macOS platform: change default value of Fl::use_high_res_GL() from 0 to 1.
Build and Test / build-linux (push) Canceled after 0s
Build and Test / build-wayland (push) Canceled after 0s
Build and Test / build-wayland-arm64 (push) Canceled after 0s
Build and Test / build-macos (push) Canceled after 0s
Build and Test / build-windows (push) Canceled after 0s
Build and Test / build-windows-arm (push) Canceled after 0s
Build and Test / build-linux (push) Canceled after 0s
Build and Test / build-wayland (push) Canceled after 0s
Build and Test / build-wayland-arm64 (push) Canceled after 0s
Build and Test / build-macos (push) Canceled after 0s
Build and Test / build-windows (push) Canceled after 0s
Build and Test / build-windows-arm (push) Canceled after 0s
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -931,34 +931,6 @@ Set <tt>"Print Front Window" = "";</tt> therein so the application menu doesn't
|
||||
To localize the application name itself, create a file <tt>InfoPlist.strings</tt> in each .lproj directory
|
||||
and put <tt>CFBundleName = "localized name";</tt> 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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
+9
-7
@@ -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_;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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]);
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -106,7 +106,6 @@ void overlay_sides_cb(Fl_Widget *o, void *p) {
|
||||
#include <stdio.h>
|
||||
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);
|
||||
|
||||
@@ -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] == '-') {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user