public static DisplayMode[] getDisplayModes () { GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice device = genv.getDefaultScreenDevice(); java.awt.DisplayMode desktopMode = device.getDisplayMode(); java.awt.DisplayMode[] displayModes = device.getDisplayModes(); ArrayList<DisplayMode> modes = new ArrayList<DisplayMode>(); int idx = 0; for (java.awt.DisplayMode mode : displayModes) { boolean duplicate = false; for (int i = 0; i < modes.size(); i++) { if (modes.get(i).width == mode.getWidth() && modes.get(i).height == mode.getHeight() && modes.get(i).bitsPerPixel == mode.getBitDepth()) { duplicate = true; break; } } if (duplicate) continue; if (mode.getBitDepth() != desktopMode.getBitDepth()) continue; modes.add(new LwjglApplicationConfigurationDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode .getBitDepth())); } return modes.toArray(new DisplayMode[modes.size()]); } }
public static DisplayMode[] getDisplayModes () { GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice device = genv.getDefaultScreenDevice(); java.awt.DisplayMode desktopMode = device.getDisplayMode(); java.awt.DisplayMode[] displayModes = device.getDisplayModes(); ArrayList<DisplayMode> modes = new ArrayList<DisplayMode>(); int idx = 0; for (java.awt.DisplayMode mode : displayModes) { boolean duplicate = false; for (int i = 0; i < modes.size(); i++) { if (modes.get(i).width == mode.getWidth() && modes.get(i).height == mode.getHeight() && modes.get(i).bitsPerPixel == mode.getBitDepth()) { duplicate = true; break; } } if (duplicate) continue; if (mode.getBitDepth() != desktopMode.getBitDepth()) continue; modes.add(new LwjglApplicationConfigurationDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode .getBitDepth())); } return modes.toArray(new DisplayMode[modes.size()]); } }
java.awt.DisplayMode useDM = null; int max = 0; for(java.awt.DisplayMode dm : VRdev.getDisplayModes()) { int check = dm.getHeight() + dm.getWidth() + dm.getRefreshRate() + dm.getBitDepth(); if( check > max ) {
java.awt.DisplayMode useDM = null; int max = 0; for(java.awt.DisplayMode dm : VRdev.getDisplayModes()) { int check = dm.getHeight() + dm.getWidth() + dm.getRefreshRate() + dm.getBitDepth(); if( check > max ) {
modes = device.getDisplayModes(); Arrays.sort(modes, new DisplayModeSorter());
final DisplayMode[] displayModes = gd.getDisplayModes(); DisplayMode multiBitsDepthSupportedDisplayMode = null; DisplayMode refreshRateUnknownDisplayMode = null;
GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment() .getScreenDevices(); for (int i = 0; i < devices.length; i++) { GraphicsDevice dev = devices[i]; System.out.println("device " + i); DisplayMode[] modes = dev.getDisplayModes(); for (int j = 0; j < modes.length; j++) { DisplayMode m = modes[j]; System.out.println(" " + j + ": " + m.getWidth() + " x " + m.getHeight()); } }
protected List<MyDisplayMode> getResolutions(GraphicsDevice device) { //Get from the system DisplayMode[] modes = device.getDisplayModes(); List<MyDisplayMode> displayModes = new ArrayList<>(modes.length); //Loop them through for (DisplayMode dm : modes) { //They may already exist, then just add the possible resfresh rate MyDisplayMode mdm = new MyDisplayMode(dm); if (displayModes.contains(mdm)) { mdm = displayModes.get(displayModes.indexOf(mdm)); mdm.addRefreshRate(dm); } else { displayModes.add(mdm); } } return displayModes; }
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); for (DisplayMode dm : gd.getDisplayModes()) { System.out.println(dm.getWidth() + "x" + dm.getHeight() + "@" + dm.getRefreshRate()); }
private ComboBoxModel makeResolutions() { MutableComboBoxModel comboBox = new DefaultComboBoxModel(); comboBox.addElement("Native"); Set<String> resolutions = new HashSet<String>(); GraphicsDevice localDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); DisplayMode[] displayModes = localDevice.getDisplayModes(); for (int i = 0; displayModes != null && i < displayModes.length; i++) { DisplayMode displayMode = displayModes[i]; if (displayMode.getBitDepth() == MainGUI.displayModeBitDepth) { String resolution = String.format("%dx%d", displayMode.getWidth(), displayMode.getHeight()); if (!resolutions.contains(resolution)) { comboBox.addElement(resolution); resolutions.add(resolution); } } } return comboBox; }
for (final DisplayMode display : dev.getDisplayModes())
GraphicsDevice gd, int width, int height, int desiredDepth, int minimumDepth) DisplayMode[] modes = gd.getDisplayModes(); final int ddepth = desiredDepth;
public static DisplayMode[] getDisplayModes () { GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice device = genv.getDefaultScreenDevice(); java.awt.DisplayMode desktopMode = device.getDisplayMode(); java.awt.DisplayMode[] displayModes = device.getDisplayModes(); ArrayList<DisplayMode> modes = new ArrayList<DisplayMode>(); int idx = 0; for (java.awt.DisplayMode mode : displayModes) { boolean duplicate = false; for (int i = 0; i < modes.size(); i++) { if (modes.get(i).width == mode.getWidth() && modes.get(i).height == mode.getHeight() && modes.get(i).bitsPerPixel == mode.getBitDepth()) { duplicate = true; break; } } if (duplicate) continue; if (mode.getBitDepth() != desktopMode.getBitDepth()) continue; modes.add(new LwjglApplicationConfigurationDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode .getBitDepth())); } return modes.toArray(new DisplayMode[modes.size()]); } }
GraphicsDevice gd, int width, int height, int desiredDepth, int minimumDepth) DisplayMode[] modes = gd.getDisplayModes(); final int ddepth = desiredDepth;
private void changeScreenResolution(int width, int height) { // Find the matching display mode with the preferred refresh rate // (or the highest refresh rate if the preferred refresh rate is not found). GraphicsDevice localDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); DisplayMode[] displayModes = localDevice.getDisplayModes(); DisplayMode bestDisplayMode = null; for (int i = 0; displayModes != null && i < displayModes.length; i++) { DisplayMode dispMode = displayModes[i]; if (dispMode.getWidth() == width && dispMode.getHeight() == height && dispMode.getBitDepth() == displayModeBitDepth) { if (bestDisplayMode == null || (bestDisplayMode.getRefreshRate() < dispMode.getRefreshRate() && bestDisplayMode.getRefreshRate() != preferredDisplayModeRefreshRate)) { bestDisplayMode = dispMode; } } } if (bestDisplayMode != null) { changeScreenResolution(bestDisplayMode); } }
@Override public void enterFullScreenMode() { GraphicsDevice graphicsDevice = getScreenDevice(); if (graphicsDevice.isFullScreenSupported()) { onBeforeEnterFullScreenMode(); graphicsDevice.setFullScreenWindow(window); DisplayMode displayMode = getDisplayMode(graphicsDevice.getDisplayModes()); if (displayMode != null) { graphicsDevice.setDisplayMode(displayMode); } } }
modes = device.getDisplayModes(); Arrays.sort(modes, new DisplayModeSorter());
static public DisplayMode[] getDisplayModes () { GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); java.awt.DisplayMode desktopMode = device.getDisplayMode(); java.awt.DisplayMode[] displayModes = device.getDisplayModes(); Array<DisplayMode> modes = new Array(); outer: for (java.awt.DisplayMode mode : displayModes) { for (DisplayMode other : modes) if (other.width == mode.getWidth() && other.height == mode.getHeight() && other.bitsPerPixel == mode.getBitDepth()) continue outer; // Duplicate. if (mode.getBitDepth() != desktopMode.getBitDepth()) continue; modes.add(new JglfwDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getBitDepth())); } return modes.toArray(DisplayMode.class); }
/** * Check if the display mode is supported. * * @param display The display mode to check. * @return Supported display, <code>null</code> else. */ private DisplayMode isSupported(DisplayMode display) { final DisplayMode[] supported = dev.getDisplayModes(); for (final DisplayMode current : supported) { final boolean multiDepth = current.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI && display.equals(current); if (multiDepth || current.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI && display.getWidth() == current.getWidth() && display.getHeight() == current.getHeight()) { return current; } } return null; }
@Override protected void collectNativeMonitorModesAndDevicesImpl(final Cache cache) { final GraphicsDevice awtGD = ((AWTGraphicsDevice)getDisplay().getGraphicsDevice()).getGraphicsDevice(); final DisplayMode[] awtModes = awtGD.getDisplayModes(); for(int i=0; i<awtModes.length; i++) { getModeProps(cache, awtModes[i]); } final MonitorMode currentMode = getModeProps(cache, awtGD.getDisplayMode()); final int[] props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES - 1 - MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES]; int i = 0; props[i++] = props.length; props[i++] = 0; // crt_idx props[i++] = ScreenImpl.default_sm_widthmm; // FIXME props[i++] = ScreenImpl.default_sm_heightmm; // FIXME props[i++] = 0; // rotated viewport x pixel-units props[i++] = 0; // rotated viewport y pixel-units props[i++] = currentMode.getRotatedWidth(); // rotated viewport width pixel-units props[i++] = currentMode.getRotatedHeight(); // rotated viewport height pixel-units props[i++] = 0; // rotated viewport x window-units props[i++] = 0; // rotated viewport y window-units props[i++] = currentMode.getRotatedWidth(); // rotated viewport width window-units props[i++] = currentMode.getRotatedHeight(); // rotated viewport height window-units MonitorModeProps.streamInMonitorDevice(null, cache, this, cache.monitorModes, currentMode, props, 0); }