Add new LWJGL API Display.getPixelScaleFactor() for use in high DPI
modes, like HiDPI retina mode on OS X.
This commit is contained in:
parent
225bd176cb
commit
eb2e7176b8
|
@ -1348,4 +1348,27 @@ public final class Display {
|
|||
|
||||
return height;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return this method will return the pixel scale factor of the Display window.
|
||||
*
|
||||
* This method should be used when running in high DPI mode. In such modes Operating
|
||||
* Systems will scale the Display window to avoid the window shrinking due to high
|
||||
* resolutions. The OpenGL frame buffer will however use the higher resolution and
|
||||
* not be scaled to match the Display window size.
|
||||
*
|
||||
* OpenGL methods that require pixel dependent values e.g. glViewport, glTexImage2D,
|
||||
* glReadPixels, etc can convert the scaled Display and Mouse coordinates to the
|
||||
* correct high resolution value by multiplying them by the pixel scale factor.
|
||||
*
|
||||
* e.g. Display.getWidth() * Display.getPixelScaleFactor() will return the high DPI
|
||||
* width of the OpenGL frame buffer. Whereas Display.getWidth() will be the same as
|
||||
* the OpenGL frame buffer in non high DPI mode.
|
||||
*
|
||||
* Where high DPI mode is not available this method will just return 1.0f therefore
|
||||
* not have any effect on values that are multiplied by it.
|
||||
*/
|
||||
public static float getPixelScaleFactor() {
|
||||
return display_impl.getPixelScaleFactor();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,4 +192,9 @@ interface DisplayImplementation extends InputImplementation {
|
|||
* @return this method will return the top-left y position of the Display window.
|
||||
*/
|
||||
int getY();
|
||||
|
||||
/**
|
||||
* @return this method will return the pixel scale factor of the Display window useful for high resolution modes.
|
||||
*/
|
||||
float getPixelScaleFactor();
|
||||
}
|
||||
|
|
|
@ -1459,6 +1459,10 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
return false;
|
||||
}
|
||||
|
||||
public float getPixelScaleFactor() {
|
||||
return 1f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class for managing Compiz's workarounds. We need this to enable Legacy
|
||||
* Fullscreen Support in Compiz, else we'll have trouble with fullscreen windows
|
||||
|
|
|
@ -623,4 +623,8 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
return nWasResized(window);
|
||||
}
|
||||
|
||||
public float getPixelScaleFactor() {
|
||||
return 1f;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1192,6 +1192,10 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
return false;
|
||||
}
|
||||
|
||||
public float getPixelScaleFactor() {
|
||||
return 1f;
|
||||
}
|
||||
|
||||
private static final class Rect {
|
||||
public int top;
|
||||
public int bottom;
|
||||
|
|
Loading…
Reference in New Issue