I want to understand more about inside world of LibGDX.
For example inside Graphics.java
, I find the following:
/** @return the width in pixels of the display surface */
public int getWidth ();
However, I can't find the source code of getWidth()
method.
Where can I find the getWidth()
method source code?
There is a different implementation of that interface for each of the available backends/platforms.
In the LWJGL backend, the implementation looks like this for example:
public int getWidth () {
if (canvas != null)
return Math.max(1, canvas.getWidth());
else
return (int)(Display.getWidth() * Display.getPixelScaleFactor());
}
The actual implementation is delegated once more to either the AWT Canvas, or the LWJGL Display.
The general idea behind these kind of interfaces can be found everywhere in LibGDX. You can also do platform specific code yourself. It is descibed in the wiki.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With