mirror of
https://github.com/fltk/fltk.git
synced 2026-06-02 15:46:52 +08:00
Make Fl_Gl_Window::pixels_per_unit() return a float (rather than int) value.
This is compatible with future scaling factors applicable to the GUI. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@11787 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+4
-4
@@ -239,9 +239,9 @@ public:
|
||||
\version 1.3.4
|
||||
*/
|
||||
#ifdef __APPLE__
|
||||
int pixels_per_unit();
|
||||
float pixels_per_unit();
|
||||
#else
|
||||
int pixels_per_unit() { return 1; }
|
||||
float 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
|
||||
@@ -250,7 +250,7 @@ public:
|
||||
between low and high resolution displays and automatically adjusts the returned value.
|
||||
\version 1.3.4
|
||||
*/
|
||||
int pixel_w() { return pixels_per_unit() * w(); }
|
||||
int pixel_w() { return int(pixels_per_unit() * w() + 0.5); }
|
||||
/** 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,
|
||||
@@ -258,7 +258,7 @@ public:
|
||||
between low and high resolution displays and automatically adjusts the returned value.
|
||||
\version 1.3.4
|
||||
*/
|
||||
int pixel_h() { return pixels_per_unit() * h(); }
|
||||
int pixel_h() { return int(pixels_per_unit() * h() + 0.5); }
|
||||
|
||||
~Fl_Gl_Window();
|
||||
/**
|
||||
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
data[0] *= factor;
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 24*sizeof(GLfloat), 4*sizeof(GLfloat), data);
|
||||
redraw();
|
||||
add_output("push Fl_Gl_Window::pixels_per_unit()=%d\n", pixels_per_unit());
|
||||
add_output("push Fl_Gl_Window::pixels_per_unit()=%d\n", int(pixels_per_unit()));
|
||||
return 1;
|
||||
}
|
||||
return Fl_Gl_Window::handle(event);
|
||||
|
||||
@@ -53,7 +53,7 @@ static Fl_RGB_Image* capture_gl_rectangle(Fl_Gl_Window *glw, int x, int y, int w
|
||||
{
|
||||
#if defined(__APPLE__)
|
||||
const int bytesperpixel = 4;
|
||||
int factor = glw->pixels_per_unit();
|
||||
float factor = glw->pixels_per_unit();
|
||||
if (factor > 1) {
|
||||
w *= factor; h *= factor; x *= factor; y *= factor;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ void Fl_Gl_Window::show() {
|
||||
|
||||
#if defined(__APPLE__)
|
||||
|
||||
int Fl_Gl_Window::pixels_per_unit()
|
||||
float Fl_Gl_Window::pixels_per_unit()
|
||||
{
|
||||
return (fl_mac_os_version >= 100700 && Fl::use_high_res_GL() && Fl_X::i(this) && Fl_X::i(this)->mapped_to_retina()) ? 2 : 1;
|
||||
}
|
||||
|
||||
@@ -83,9 +83,9 @@ int Fl_Glut_Window::handle(int event) {
|
||||
make_current();
|
||||
int ex = Fl::event_x();
|
||||
int ey = Fl::event_y();
|
||||
int factor = pixels_per_unit();
|
||||
ex *= factor;
|
||||
ey *= factor;
|
||||
float factor = pixels_per_unit();
|
||||
ex = int(ex * factor + 0.5);
|
||||
ey = int(ey * factor + 0.5);
|
||||
int button;
|
||||
switch (event) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user