com.jogamp.newt.util.MonitorModeUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jogl Show documentation
Show all versions of jogl Show documentation
Java™ Binding for the OpenGL® API (Atomic Jar files)
The newest version!
/**
* Copyright 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
package com.jogamp.newt.util;
import com.jogamp.newt.MonitorMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.jogamp.nativewindow.util.DimensionImmutable;
import com.jogamp.nativewindow.util.SurfaceSize;
/**
* Convenient {@link com.jogamp.newt.MonitorMode} utility methods,
* filters etc.
*/
public class MonitorModeUtil {
public static int getIndex(final List monitorModes, final MonitorMode search) {
return monitorModes.indexOf(search);
}
public static int getIndexByHashCode(final List monitorModes, final MonitorMode search) {
if( null!=monitorModes && monitorModes.size()>0 ) {
for (int i=0; i monitorModes, final MonitorMode.SizeAndRRate sizeAndRate, final int modeId, final int rotation) {
if( null!=monitorModes && monitorModes.size()>0 ) {
for (int i=0; i monitorModes, final boolean ascendingOrder) {
if( ascendingOrder ) {
Collections.sort(monitorModes);
} else {
Collections.sort(monitorModes, MonitorMode.monitorModeComparatorInv);
}
}
/**
*
* @param monitorModes
* @param surfaceSize
* @return modes with exact {@link SurfaceSize}. May return zero sized list for non.
*/
public static List filterBySurfaceSize(final List monitorModes, final SurfaceSize surfaceSize) {
final List out = new ArrayList();
if( null!=monitorModes && monitorModes.size()>0 ) {
for (int i=0; null!=monitorModes && i filterByRotation(final List monitorModes, final int rotation) {
final List out = new ArrayList();
if( null!=monitorModes && monitorModes.size()>0 ) {
for (int i=0; null!=monitorModes && i filterByBpp(final List monitorModes, final int bitsPerPixel) {
final List out = new ArrayList();
if( null!=monitorModes && monitorModes.size()>0 ) {
for (int i=0; null!=monitorModes && i filterByFlags(final List monitorModes, final int flags) {
final List out = new ArrayList();
if( null!=monitorModes && monitorModes.size()>0 ) {
for (int i=0; null!=monitorModes && i filterByResolution(final List monitorModes, final DimensionImmutable resolution) {
final List out = new ArrayList();
if( null!=monitorModes && monitorModes.size()>0 ) {
final int resolution_sq = resolution.getHeight()*resolution.getWidth();
int mode_dsq=Integer.MAX_VALUE, mode_dsq_idx=0;
for (int i=0; null!=monitorModes && i filterByRate(final List monitorModes, final float refreshRate) {
final List out = new ArrayList();
if( null!=monitorModes && monitorModes.size()>0 ) {
float mode_dr = Float.MAX_VALUE;
int mode_dr_idx = -1;
for (int i=0; null!=monitorModes && i getHighestAvailableBpp(final List monitorModes) {
if( null!=monitorModes && monitorModes.size()>0 ) {
int highest = -1;
for (int i=0; null!=monitorModes && i < monitorModes.size(); i++) {
final MonitorMode mode = monitorModes.get(i);
final int bpp = mode.getSurfaceSize().getBitsPerPixel();
if (bpp > highest) {
highest = bpp;
}
}
return filterByBpp(monitorModes, highest);
}
return new ArrayList();
}
/**
*
* @param monitorModes
* @return modes with highest available refresh rate. May return zero sized list for non.
*/
public static List getHighestAvailableRate(final List monitorModes) {
if( null!=monitorModes && monitorModes.size()>0 ) {
float highest = -1;
for (int i=0; null!=monitorModes && i < monitorModes.size(); i++) {
final MonitorMode mode = monitorModes.get(i);
final float rate = mode.getRefreshRate();
if (rate > highest) {
highest = rate;
}
}
return filterByRate(monitorModes, highest);
}
return new ArrayList();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy