Made Linux specific code use reflection to avoid compilation errors on other platforms
This commit is contained in:
parent
91813bfc09
commit
8364443052
|
@ -39,14 +39,7 @@ import org.lwjgl.BufferUtils;
|
||||||
import java.awt.GraphicsDevice;
|
import java.awt.GraphicsDevice;
|
||||||
import java.awt.GraphicsConfiguration;
|
import java.awt.GraphicsConfiguration;
|
||||||
|
|
||||||
/*
|
import java.lang.reflect.Method;
|
||||||
* Import the needed SUN specific classes. They
|
|
||||||
* are needed since there is no official way to access
|
|
||||||
* the screen and visual from GraphicsDevice and
|
|
||||||
* GraphicsConfiguration respectively.
|
|
||||||
*/
|
|
||||||
import sun.awt.X11GraphicsDevice;
|
|
||||||
import sun.awt.X11GraphicsConfig;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $Id$
|
* $Id$
|
||||||
|
@ -55,14 +48,24 @@ import sun.awt.X11GraphicsConfig;
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
final class LinuxCanvasImplementation implements AWTCanvasImplementation {
|
final class LinuxCanvasImplementation implements AWTCanvasImplementation {
|
||||||
static int getScreenFromDevice(GraphicsDevice device) {
|
static int getScreenFromDevice(GraphicsDevice device) throws LWJGLException {
|
||||||
X11GraphicsDevice x11_device = (X11GraphicsDevice)device;
|
try {
|
||||||
return x11_device.getScreen();
|
Method getScreen_method = device.getClass().getMethod("getScreen()", null);
|
||||||
|
Integer screen = (Integer)getScreen_method.invoke(null, null);
|
||||||
|
return screen.intValue();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new LWJGLException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getVisualIDFromConfiguration(GraphicsConfiguration configuration) {
|
private static int getVisualIDFromConfiguration(GraphicsConfiguration configuration) throws LWJGLException {
|
||||||
X11GraphicsConfig x11_config = (X11GraphicsConfig)configuration;
|
try {
|
||||||
return x11_config.getVisual();
|
Method getVisual_method = configuration.getClass().getMethod("getVisual()", null);
|
||||||
|
Integer visual = (Integer)getVisual_method.invoke(null, null);
|
||||||
|
return visual.intValue();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new LWJGLException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PeerInfo createPeerInfo(AWTGLCanvas canvas) throws LWJGLException {
|
public PeerInfo createPeerInfo(AWTGLCanvas canvas) throws LWJGLException {
|
||||||
|
@ -75,7 +78,6 @@ final class LinuxCanvasImplementation implements AWTCanvasImplementation {
|
||||||
* @return The GraphicsConfiguration corresponding to a visual that matches the pixel format.
|
* @return The GraphicsConfiguration corresponding to a visual that matches the pixel format.
|
||||||
*/
|
*/
|
||||||
public GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException {
|
public GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException {
|
||||||
X11GraphicsDevice x11_device = (X11GraphicsDevice)device;
|
|
||||||
int screen = getScreenFromDevice(device);
|
int screen = getScreenFromDevice(device);
|
||||||
int visual_id_matching_format = findVisualIDFromFormat(screen, pixel_format);
|
int visual_id_matching_format = findVisualIDFromFormat(screen, pixel_format);
|
||||||
GraphicsConfiguration[] configurations = device.getConfigurations();
|
GraphicsConfiguration[] configurations = device.getConfigurations();
|
||||||
|
|
Loading…
Reference in New Issue