01: /*
02: * $RCSfile: X11NativeScreenInfo.java,v $
03: *
04: * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06: *
07: * This code is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU General Public License version 2 only, as
09: * published by the Free Software Foundation. Sun designates this
10: * particular file as subject to the "Classpath" exception as provided
11: * by Sun in the LICENSE file that accompanied this code.
12: *
13: * This code is distributed in the hope that it will be useful, but WITHOUT
14: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16: * version 2 for more details (a copy is included in the LICENSE file that
17: * accompanied this code).
18: *
19: * You should have received a copy of the GNU General Public License version
20: * 2 along with this work; if not, write to the Free Software Foundation,
21: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22: *
23: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24: * CA 95054 USA or visit www.sun.com if you need additional information or
25: * have any questions.
26: *
27: * $Revision: 1.2 $
28: * $Date: 2008/02/28 20:17:57 $
29: * $State: Exp $
30: */
31:
32: package javax.media.j3d;
33:
34: import java.awt.GraphicsDevice;
35: import sun.awt.X11GraphicsDevice;
36:
37: /**
38: * Native screen info class. A singleton instance of this class is created by
39: * a factory method in the base class using reflection.
40: */
41: class X11NativeScreenInfo extends NativeScreenInfo {
42: private static long display = 0;
43: private static boolean glxChecked = false;
44: private static boolean isGLX13;
45:
46: private static native long openDisplay();
47:
48: private static native boolean queryGLX13(long display);
49:
50: X11NativeScreenInfo() {
51: }
52:
53: // Fix for issue 20.
54: // This method will return true if glx version is 1.3 or higher,
55: // else return false.
56: static synchronized boolean isGLX13() {
57: if (!glxChecked) {
58: // Open a new static display connection if one is not already opened.
59: getStaticDisplay();
60:
61: // Query for glx1.3 support.
62: isGLX13 = queryGLX13(getStaticDisplay());
63: glxChecked = true;
64: }
65:
66: return isGLX13;
67: }
68:
69: private static synchronized long getStaticDisplay() {
70: if (display == 0) {
71: display = openDisplay();
72: }
73: return display;
74: }
75:
76: @Override
77: long getDisplay() {
78: // Open a new static display connection if one is not already opened
79: return getStaticDisplay();
80: }
81:
82: @Override
83: int getScreen(GraphicsDevice graphicsDevice) {
84: // Get the screen number
85: return ((X11GraphicsDevice) graphicsDevice).getScreen();
86: }
87:
88: // Ensure that the native libraries are loaded
89: static {
90: VirtualUniverse.loadLibraries();
91: }
92: }
|