diff options
| author | Manolo Gouy <Manolo> | 2015-12-02 09:59:37 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2015-12-02 09:59:37 +0000 |
| commit | 22af09dae7a2e17f0b1253030fd3cb7c6ce92799 (patch) | |
| tree | 9e715f50811df7a6d9a6647a61e289b06371a936 /FL | |
| parent | 30e572985b24eb685e3d9eb0112017c4fc318b4d (diff) | |
Mac OS: support for high resolution OpenGL windows.
Methods Fl::event_x_pixel() and Fl::event_y_pixel() committed at r.10941
are removed. Instead method Fl_Gl_Window::pixels_per_unit() is added.
The documentation explains in more detail how to write cross-platform
FLTK code supporting high resolution OpenGL windows on retina displays.
The examples/OpenGL3test.cxx app exercises Fl_Gl_Window::pixels_per_unit().
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10945 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'FL')
| -rw-r--r-- | FL/Fl.H | 26 | ||||
| -rw-r--r-- | FL/Fl_Gl_Window.H | 21 | ||||
| -rw-r--r-- | FL/mac.H | 1 |
3 files changed, 15 insertions, 33 deletions
@@ -135,9 +135,6 @@ public: // should be private! static int e_y; static int e_x_root; static int e_y_root; -#ifdef __APPLE__ - static Fl_Window *e_window_; -#endif static int e_dx; static int e_dy; static int e_state; @@ -604,29 +601,6 @@ public: event_x(),event_y(). */ static int event_y_root() {return e_y_root;} -#ifdef __APPLE__ - static int event_x_pixel(); - static int event_y_pixel(); -#else - /** Horizontal position in pixels of the mouse event relative to the Fl_Window it was passed to. - Generally identical with Fl::event_x(), but for OpenGL windows of macintosh computers - with a 'retina' display, and if Fl::use_high_res_GL(bool) is set to true, - the returned position, measured in pixels, differs from Fl::event_x(), measured in FLTK units. - \version 1.3.4 - */ - static int event_x_pixel() { - return e_x; - } - /** Vertical position in pixels of the mouse event relative to the Fl_Window it was passed to. - Generally identical with Fl::event_y(), but for OpenGL windows of macintosh computers - with a 'retina' display, and if Fl::use_high_res_GL(bool) is set to true, - the returned position, measured in pixels, differs from Fl::event_y(), measured in FLTK units. - \version 1.3.4 - */ - static int event_y_pixel() { - return e_y; - } -#endif /** Returns the current horizontal mouse scrolling associated with the FL_MOUSEWHEEL event. Right is positive. diff --git a/FL/Fl_Gl_Window.H b/FL/Fl_Gl_Window.H index e8bd11aff..543aa41f3 100644 --- a/FL/Fl_Gl_Window.H +++ b/FL/Fl_Gl_Window.H @@ -229,10 +229,20 @@ public: // Note: Doxygen docs in Fl_Widget.H to avoid redundancy. virtual Fl_Gl_Window* as_gl_window() {return this;} -#if defined(__APPLE__) - int pixel_w(); - int pixel_h(); +#ifdef __APPLE__ + int pixels_per_unit(); #else + /** The number of pixels per FLTK unit of length for the window. + Returns 1, except for a window mapped to + an Apple 'retina' display, and if Fl::use_high_res_GL(bool) is set to true, + when it returns 2. This method dynamically adjusts its value when the window + is moved to/from a retina display. This method is useful, e.g., to convert, + in a window's handle() method, the FLTK units returned by Fl::event_x() and + Fl::event_y() to the pixel units used by the OpenGL source code. + \version 1.3.4 + */ + int pixels_per_unit() { return 1; } +#endif /** Gives the window width in OpenGL pixels. Generally identical with the result of the w() function, but for a window mapped to an Apple 'retina' display, and if Fl::use_high_res_GL(bool) is set to true, @@ -240,7 +250,7 @@ public: between low and high resolution displays and automatically adjusts the returned value. \version 1.3.4 */ - int pixel_w() { return w(); } + int pixel_w() { return pixels_per_unit() * w(); } /** Gives the window height in OpenGL pixels. Generally identical with the result of the h() function, but for a window mapped to an Apple 'retina' display, and if Fl::use_high_res_GL(bool) is set to true, @@ -248,8 +258,7 @@ public: between low and high resolution displays and automatically adjusts the returned value. \version 1.3.4 */ - int pixel_h() { return h(); } -#endif + int pixel_h() { return pixels_per_unit() * h(); } ~Fl_Gl_Window(); /** @@ -181,7 +181,6 @@ public: static void q_begin_image(CGRect&, int x, int y, int w, int h); static void q_end_image(); // Cocoa additions - static int resolution_scaling_factor(Fl_Window*); static NSOpenGLPixelFormat *mode_to_NSOpenGLPixelFormat(int mode, const int*); // computes NSOpenGLPixelFormat from Gl window's mode static NSOpenGLContext* create_GLcontext_for_window(NSOpenGLPixelFormat *pixelformat, NSOpenGLContext *shared_ctx, Fl_Window *window); static void GLcontext_update(NSOpenGLContext*); |
