Make Fl_Gl_Window::pixels_per_unit() return a float (rather than int) value.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11794 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
0ff9df96d9
commit
22596d3f5f
@ -208,7 +208,7 @@ public:
|
|||||||
// Note: Doxygen docs in Fl_Widget.H to avoid redundancy.
|
// Note: Doxygen docs in Fl_Widget.H to avoid redundancy.
|
||||||
virtual Fl_Gl_Window* as_gl_window() {return this;}
|
virtual Fl_Gl_Window* as_gl_window() {return this;}
|
||||||
|
|
||||||
int pixels_per_unit();
|
float pixels_per_unit();
|
||||||
/** Gives the window width in OpenGL pixels.
|
/** Gives the window width in OpenGL pixels.
|
||||||
Generally identical with the result of the w() function, but for a window mapped to
|
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,
|
an Apple 'retina' display, and if Fl::use_high_res_GL(bool) is set to true,
|
||||||
@ -216,7 +216,7 @@ public:
|
|||||||
between low and high resolution displays and automatically adjusts the returned value.
|
between low and high resolution displays and automatically adjusts the returned value.
|
||||||
\version 1.3.4
|
\version 1.3.4
|
||||||
*/
|
*/
|
||||||
int pixel_w() { return pixels_per_unit() * w(); }
|
int pixel_w() { return int(pixels_per_unit() * w() + 0.5f); }
|
||||||
/** Gives the window height in OpenGL pixels.
|
/** Gives the window height in OpenGL pixels.
|
||||||
Generally identical with the result of the h() function, but for a window mapped to
|
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,
|
an Apple 'retina' display, and if Fl::use_high_res_GL(bool) is set to true,
|
||||||
@ -224,7 +224,7 @@ public:
|
|||||||
between low and high resolution displays and automatically adjusts the returned value.
|
between low and high resolution displays and automatically adjusts the returned value.
|
||||||
\version 1.3.4
|
\version 1.3.4
|
||||||
*/
|
*/
|
||||||
int pixel_h() { return pixels_per_unit() * h(); }
|
int pixel_h() { return int(pixels_per_unit() * h() + 0.5f); }
|
||||||
|
|
||||||
~Fl_Gl_Window();
|
~Fl_Gl_Window();
|
||||||
/**
|
/**
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
virtual ~Fl_Gl_Window_Driver() {}
|
virtual ~Fl_Gl_Window_Driver() {}
|
||||||
static Fl_Gl_Window_Driver *newGlWindowDriver(Fl_Gl_Window *w);
|
static Fl_Gl_Window_Driver *newGlWindowDriver(Fl_Gl_Window *w);
|
||||||
static Fl_Gl_Window_Driver *global();
|
static Fl_Gl_Window_Driver *global();
|
||||||
virtual int pixels_per_unit() {return 1;}
|
virtual float pixels_per_unit() {return 1;}
|
||||||
virtual void before_show(int& need_redraw) {}
|
virtual void before_show(int& need_redraw) {}
|
||||||
virtual void after_show(int need_redraw) {}
|
virtual void after_show(int need_redraw) {}
|
||||||
virtual void invalidate();
|
virtual void invalidate();
|
||||||
@ -95,7 +95,7 @@ class NSOpenGLPixelFormat;
|
|||||||
class Fl_Cocoa_Gl_Window_Driver : public Fl_Gl_Window_Driver {
|
class Fl_Cocoa_Gl_Window_Driver : public Fl_Gl_Window_Driver {
|
||||||
friend class Fl_Gl_Window_Driver;
|
friend class Fl_Gl_Window_Driver;
|
||||||
Fl_Cocoa_Gl_Window_Driver(Fl_Gl_Window *win) : Fl_Gl_Window_Driver(win) {}
|
Fl_Cocoa_Gl_Window_Driver(Fl_Gl_Window *win) : Fl_Gl_Window_Driver(win) {}
|
||||||
virtual int pixels_per_unit();
|
virtual float pixels_per_unit();
|
||||||
virtual void before_show(int& need_redraw);
|
virtual void before_show(int& need_redraw);
|
||||||
virtual void after_show(int need_redraw);
|
virtual void after_show(int need_redraw);
|
||||||
virtual int mode_(int m, const int *a);
|
virtual int mode_(int m, const int *a);
|
||||||
|
@ -167,7 +167,7 @@ public:
|
|||||||
data[0] *= factor;
|
data[0] *= factor;
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, 24*sizeof(GLfloat), 4*sizeof(GLfloat), data);
|
glBufferSubData(GL_ARRAY_BUFFER, 24*sizeof(GLfloat), 4*sizeof(GLfloat), data);
|
||||||
redraw();
|
redraw();
|
||||||
add_output("push Fl_Gl_Window::pixels_per_unit()=%d\n", pixels_per_unit());
|
add_output("push Fl_Gl_Window::pixels_per_unit()=%.1f\n", pixels_per_unit());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return Fl_Gl_Window::handle(event);
|
return Fl_Gl_Window::handle(event);
|
||||||
|
@ -404,7 +404,7 @@ int Fl_Gl_Window::gl_plugin_linkage() {
|
|||||||
Fl::event_y() to the pixel units used by the OpenGL source code.
|
Fl::event_y() to the pixel units used by the OpenGL source code.
|
||||||
\version 1.3.4
|
\version 1.3.4
|
||||||
*/
|
*/
|
||||||
int Fl_Gl_Window::pixels_per_unit() {
|
float Fl_Gl_Window::pixels_per_unit() {
|
||||||
return pGlWindowDriver->pixels_per_unit();
|
return pGlWindowDriver->pixels_per_unit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,7 +470,7 @@ void Fl_Cocoa_Gl_Window_Driver::after_show(int need_redraw) {
|
|||||||
if(need_redraw) pWindow->redraw();//necessary only after creation of a top-level GL window
|
if(need_redraw) pWindow->redraw();//necessary only after creation of a top-level GL window
|
||||||
}
|
}
|
||||||
|
|
||||||
int Fl_Cocoa_Gl_Window_Driver::pixels_per_unit()
|
float Fl_Cocoa_Gl_Window_Driver::pixels_per_unit()
|
||||||
{
|
{
|
||||||
return (fl_mac_os_version >= 100700 && Fl::use_high_res_GL() && Fl_X::i(pWindow) &&
|
return (fl_mac_os_version >= 100700 && Fl::use_high_res_GL() && Fl_X::i(pWindow) &&
|
||||||
Fl_Cocoa_Window_Driver::driver(pWindow)->mapped_to_retina()) ? 2 : 1;
|
Fl_Cocoa_Window_Driver::driver(pWindow)->mapped_to_retina()) ? 2 : 1;
|
||||||
|
@ -63,7 +63,7 @@ static uchar *convert_BGRA_to_RGB(uchar *baseAddress, int w, int h, int mByteWid
|
|||||||
|
|
||||||
Fl_RGB_Image* Fl_OpenGL_Display_Device::capture_gl_rectangle(Fl_Gl_Window* glw, int x, int y, int w, int h)
|
Fl_RGB_Image* Fl_OpenGL_Display_Device::capture_gl_rectangle(Fl_Gl_Window* glw, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
int factor = glw->pixels_per_unit();
|
float factor = glw->pixels_per_unit();
|
||||||
if (factor > 1) {
|
if (factor > 1) {
|
||||||
w *= factor; h *= factor; x *= factor; y *= factor;
|
w *= factor; h *= factor; x *= factor; y *= factor;
|
||||||
}
|
}
|
||||||
|
@ -74,9 +74,9 @@ int Fl_Glut_Window::handle(int event) {
|
|||||||
make_current();
|
make_current();
|
||||||
int ex = Fl::event_x();
|
int ex = Fl::event_x();
|
||||||
int ey = Fl::event_y();
|
int ey = Fl::event_y();
|
||||||
int factor = pixels_per_unit();
|
float factor = pixels_per_unit();
|
||||||
ex *= factor;
|
ex = int(ex * factor + 0.5f);
|
||||||
ey *= factor;
|
ey = int(ey * factor + 0.5f);
|
||||||
int button;
|
int button;
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user