diff options
Diffstat (limited to 'FL')
| -rw-r--r-- | FL/Fl.H | 13 | ||||
| -rw-r--r-- | FL/Fl_Gl_Window.H | 23 | ||||
| -rw-r--r-- | FL/mac.H | 9 |
3 files changed, 42 insertions, 3 deletions
@@ -125,6 +125,9 @@ typedef void (*Fl_Clipboard_Notify_Handler)(int source, void *data); class FL_EXPORT Fl { Fl() {}; // no constructor! +private: + static int use_high_res_GL_; + public: // should be private! #ifndef FL_DOXYGEN static int e_number; @@ -1206,6 +1209,16 @@ public: static void release_widget_pointer(Fl_Widget *&w); static void clear_widget_pointer(Fl_Widget const *w); /** @} */ + + /** sets whether GL windows should be drawn at high resolution on Apple + computers with retina displays + */ + static void use_high_res_GL(int val) { use_high_res_GL_ = val; } + /** returns whether GL windows should be drawn at high resolution on Apple + computers with retina displays. + Default is no. + */ + static int use_high_res_GL() { return use_high_res_GL_; } #ifdef FLTK_HAVE_CAIRO /** \defgroup group_cairo Cairo support functions and classes diff --git a/FL/Fl_Gl_Window.H b/FL/Fl_Gl_Window.H index 47fe04939..7bec39877 100644 --- a/FL/Fl_Gl_Window.H +++ b/FL/Fl_Gl_Window.H @@ -89,7 +89,7 @@ public: \code void mywindow::draw() { if (!valid()) { - glViewport(0,0,w(),h()); + glViewport(0,0,pixel_w(),pixel_h()); glFrustum(...); ...other initialization... } @@ -168,7 +168,8 @@ public: int mode(int a) {return mode(a,0);} /** See Fl_Mode mode() const */ int mode(const int *a) {return mode(0, a);} - /** void See void context(void* v, int destroy_flag) */ + /** Returns a pointer to the GLContext that this window is using. + \see void context(void* v, int destroy_flag) */ void* context() const {return context_;} void context(void*, int destroy_flag = 0); void make_current(); @@ -201,6 +202,24 @@ public: // Note: Doxygen docs in Fl_Widget.H to avoid redundancy. virtual Fl_Gl_Window* as_gl_window() {return this;} +#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + int pixel_w(); + int pixel_h(); +#else + /** Gives the window width in OpenGL pixels. + Generally identical with the result of the w() function, but on macintosh computers + with a 'retina' display, and if Fl::use_high_res_GL(bool) is set to true, + pixel_w() returns 2 * w(). + */ + int pixel_w() { return w(); } + /** Gives the window height in OpenGL pixels. + Generally identical with the result of the h() function, but on macintosh computers + with a 'retina' display, and if Fl::use_high_res_GL(bool) is set to true, + pixel_h() returns 2 * h(). + */ + int pixel_h() { return h(); } +#endif + ~Fl_Gl_Window(); /** Creates a new Fl_Gl_Window widget using the given size, and label string. @@ -74,8 +74,10 @@ typedef CGContextRef Fl_Offscreen; #ifdef __OBJC__ @class NSCursor; +@class NSOpenGLPixelFormat; #else class NSCursor; +class NSOpenGLPixelFormat; #endif // __OBJC__ typedef CGContextRef Fl_Offscreen; @@ -151,6 +153,8 @@ public: #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 bool mapped_to_retina(); // is window mapped to retina display? void mapped_to_retina(bool); // sets whether window is mapped to retina display + bool changed_resolution(); // did window just moved to display with another resolution? + void changed_resolution(bool);// sets whether window just moved to display with another resolution #endif // Quartz additions: CGContextRef gc; // graphics context (NULL when using QD) @@ -160,6 +164,8 @@ 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 void destroy(void); void map(void); void unmap(void); @@ -183,7 +189,8 @@ public: private: #if FLTK_ABI_VERSION >= 10304 CGRect* subRect_; // makes sure subwindow remains inside its parent window - unsigned mapped_to_retina_; // stores whether window is mapped to retina display + // stores 2 binary flags: whether window is mapped to retina display; whether resolution just changed + unsigned mapped_to_retina_; #else bool subwindow; // for ABI compatibility, useless with true subwindows #endif |
