本文整理匯總了Java中org.lwjgl.opengl.DisplayMode.getWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java DisplayMode.getWidth方法的具體用法?Java DisplayMode.getWidth怎麽用?Java DisplayMode.getWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.lwjgl.opengl.DisplayMode
的用法示例。
在下文中一共展示了DisplayMode.getWidth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Window
import org.lwjgl.opengl.DisplayMode; //導入方法依賴的package包/類
protected Window(Context context, WindowBuilder settings) {
this.fpsCap = settings.getFpsCap();
try {
getSuitableFullScreenModes();
DisplayMode resolution = getStartResolution(settings);
Display.setInitialBackground(1, 1, 1);
this.aspectRatio = (float) resolution.getWidth() / resolution.getHeight();
setResolution(resolution, settings.isFullScreen());
if (settings.hasIcon()) {
Display.setIcon(settings.getIcon());
}
Display.setVSyncEnabled(settings.isvSync());
Display.setTitle(settings.getTitle());
Display.create(new PixelFormat().withDepthBits(24).withSamples(4), context.getAttribs());
GL11.glViewport(0, 0, resolution.getWidth(), resolution.getHeight());
} catch (LWJGLException e) {
e.printStackTrace();
}
}
示例2: getDisplayMode
import org.lwjgl.opengl.DisplayMode; //導入方法依賴的package包/類
public static DisplayMode getDisplayMode(Dimension p_getDisplayMode_0_) throws LWJGLException
{
DisplayMode[] adisplaymode = Display.getAvailableDisplayModes();
for (int i = 0; i < adisplaymode.length; ++i)
{
DisplayMode displaymode = adisplaymode[i];
if (displaymode.getWidth() == p_getDisplayMode_0_.width && displaymode.getHeight() == p_getDisplayMode_0_.height && (desktopDisplayMode == null || displaymode.getBitsPerPixel() == desktopDisplayMode.getBitsPerPixel() && displaymode.getFrequency() == desktopDisplayMode.getFrequency()))
{
return displaymode;
}
}
return desktopDisplayMode;
}
示例3: getDisplayMode
import org.lwjgl.opengl.DisplayMode; //導入方法依賴的package包/類
public static DisplayMode getDisplayMode(Dimension p_getDisplayMode_0_) throws LWJGLException
{
DisplayMode[] adisplaymode = getDisplayModes();
for (int i = 0; i < adisplaymode.length; ++i)
{
DisplayMode displaymode = adisplaymode[i];
if (displaymode.getWidth() == p_getDisplayMode_0_.width && displaymode.getHeight() == p_getDisplayMode_0_.height)
{
return displaymode;
}
}
return desktopDisplayMode;
}
示例4: Window
import org.lwjgl.opengl.DisplayMode; //導入方法依賴的package包/類
protected Window(Context context, WindowBuilder settings) {
this.fpsCap = settings.getFpsCap();
try {
getSuitableFullScreenModes();
DisplayMode resolution = getStartResolution(settings);
Display.setInitialBackground(0f, 0f, 0f);
this.aspectRatio = (float) resolution.getWidth() / resolution.getHeight();
setResolution(resolution, settings.isFullScreen());
if (settings.hasIcon()) {
Display.setIcon(settings.getIcon());
}
Display.setVSyncEnabled(settings.isvSync());
Display.setTitle(settings.getTitle());
Display.create(new PixelFormat().withDepthBits(24).withSamples(4), context.getAttribs());
GL11.glViewport(0, 0, resolution.getWidth(), resolution.getHeight());
} catch (LWJGLException e) {
e.printStackTrace();
}
}
示例5: findFullscreenDisplayMode
import org.lwjgl.opengl.DisplayMode; //導入方法依賴的package包/類
/**
* from org.newdawn.slick.AppGameContainer#setDisplayMode
*/
public static DisplayMode findFullscreenDisplayMode(int targetBPP, int targetFrequency, int width, int height) throws LWJGLException {
DisplayMode[] modes = Display.getAvailableDisplayModes();
DisplayMode foundMode = null;
int freq = 0;
int bpp = 0;
for (DisplayMode current : modes) {
if (current.getWidth() != width || current.getHeight() != height) {
continue;
}
if (current.getBitsPerPixel() == targetBPP && current.getFrequency() == targetFrequency) {
return current;
}
if (current.getFrequency() >= freq && (foundMode == null || current.getBitsPerPixel() >= bpp)) {
foundMode = current;
freq = foundMode.getFrequency();
bpp = foundMode.getBitsPerPixel();
}
}
return foundMode;
}
示例6: getFullscreenDisplayMode
import org.lwjgl.opengl.DisplayMode; //導入方法依賴的package包/類
protected DisplayMode getFullscreenDisplayMode(int width, int height, int bpp, int freq){
try {
DisplayMode[] modes = Display.getAvailableDisplayModes();
for (DisplayMode mode : modes){
if (mode.getWidth() == width
&& mode.getHeight() == height
&& (mode.getBitsPerPixel() == bpp || (bpp==24&&mode.getBitsPerPixel()==32))
&& mode.getFrequency() == freq){
return mode;
}
}
} catch (LWJGLException ex) {
listener.handleError("Failed to acquire fullscreen display mode!", ex);
}
return null;
}
示例7: notifyTimeOnFullScreen
import org.lwjgl.opengl.DisplayMode; //導入方法依賴的package包/類
public void notifyTimeOnFullScreen() {
if (!FzConfig.show_time_on_fullscreen) return;
if (interval <= 0) return;
long now = getNow();
if (now == old_now || now == -1) return;
old_now = now;
Minecraft mc = Minecraft.getMinecraft();
if (!mc.isFullScreen()) {
DisplayMode desktop = Display.getDesktopDisplayMode();
if (desktop.getWidth() != mc.displayWidth || desktop.getHeight() != mc.displayHeight) {
return;
}
}
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
String msg = df.format(new Date());
if (!mentioned_disabling) {
msg += " (via FZ)";
mentioned_disabling = true;
}
ChatStyle style = new ChatStyle().setItalic(true).setColor(EnumChatFormatting.GRAY);
mc.ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText(msg).setChatStyle(style), 20392);
last_msg = msg;
}
示例8: compare
import org.lwjgl.opengl.DisplayMode; //導入方法依賴的package包/類
@Override
public int compare(DisplayMode a, DisplayMode b)
{
if (a.getWidth() != b.getWidth())
{
return (a.getWidth() > b.getWidth()) ? 1 : -1;
}
if (a.getHeight() != b.getHeight())
{
return (a.getHeight() > b.getHeight()) ? 1 : -1;
}
if (a.getBitsPerPixel() != b.getBitsPerPixel())
{
return (a.getBitsPerPixel() > b.getBitsPerPixel()) ? 1 : -1;
}
if (a.getFrequency() != b.getFrequency())
{
return (a.getFrequency() > b.getFrequency()) ? 1 : -1;
}
return 0;
}
示例9: getDisplayMode
import org.lwjgl.opengl.DisplayMode; //導入方法依賴的package包/類
public static DisplayMode getDisplayMode(Dimension dim) throws LWJGLException
{
DisplayMode[] modes = Display.getAvailableDisplayModes();
for (int i = 0; i < modes.length; ++i)
{
DisplayMode dm = modes[i];
if (dm.getWidth() == dim.width && dm.getHeight() == dim.height && (desktopDisplayMode == null || dm.getBitsPerPixel() == desktopDisplayMode.getBitsPerPixel() && dm.getFrequency() == desktopDisplayMode.getFrequency()))
{
return dm;
}
}
return desktopDisplayMode;
}
示例10: findBestDisplayMode
import org.lwjgl.opengl.DisplayMode; //導入方法依賴的package包/類
public static DisplayMode findBestDisplayMode(int width, int height) {
DisplayMode desktopMode = Display.getDesktopDisplayMode();
if (width == desktopMode.getWidth() && height == desktopMode.getHeight()) {
return desktopMode;
}
DisplayMode bestMode = null;
try {
for (DisplayMode m : Display.getAvailableDisplayModes()) {
if (width == m.getWidth() && height == m.getHeight()) {
if (null == bestMode
|| (m.isFullscreenCapable() && !bestMode.isFullscreenCapable())
|| (m.getBitsPerPixel() > bestMode.getBitsPerPixel())
|| m.getFrequency() > bestMode.getFrequency()) {
bestMode = m;
}
}
}
if (null != bestMode) {
return bestMode;
}
} catch (LWJGLException ex) {
Logger.getLogger(LwjglHelper.class.getName()).log(Level.SEVERE, null, ex);
}
return new DisplayMode(width, height);
}
示例11: doesDisplayModeExist
import org.lwjgl.opengl.DisplayMode; //導入方法依賴的package包/類
public static DisplayMode doesDisplayModeExist(EngineConfiguration config) throws LWJGLException{
DisplayMode[] modes = Display.getAvailableDisplayModes();
DisplayMode chosen = null;
for(DisplayMode mode : modes){
int width = mode.getWidth();
int height = mode.getHeight();
if(width == config.DISPLAY_WIDTH && height == config.DISPLAY_HEIGHT){
if(chosen == null){
chosen = mode;
}else{
if(isDisplayModeBetter(chosen, mode)){
chosen = mode;
}
}
}
}
return chosen;
}
示例12: isSuitableFullScreenResolution
import org.lwjgl.opengl.DisplayMode; //導入方法依賴的package包/類
private boolean isSuitableFullScreenResolution(DisplayMode resolution, DisplayMode desktopResolution) {
if (resolution.getBitsPerPixel() == desktopResolution.getBitsPerPixel()) {
if (resolution.getFrequency() == desktopResolution.getFrequency()) {
float desktopAspect = (float) desktopResolution.getWidth() / desktopResolution.getHeight();
float resAspect = (float) resolution.getWidth() / resolution.getHeight();
float check = resAspect / desktopAspect;
if (check > 0.95f && check < 1.05f) {
return resolution.getHeight() > MIN_HEIGHT;
}
}
}
return false;
}
示例13: getFullScreenDisplayMode
import org.lwjgl.opengl.DisplayMode; //導入方法依賴的package包/類
private DisplayMode getFullScreenDisplayMode(int width, int height) {
for (DisplayMode potentialMode : availableResolutions) {
if (potentialMode.getWidth() == width && potentialMode.getHeight() == height) {
return potentialMode;
}
}
return null;
}
示例14: getFullscreenDisplayModes
import org.lwjgl.opengl.DisplayMode; //導入方法依賴的package包/類
public static DisplayMode[] getFullscreenDisplayModes()
{
try
{
DisplayMode[] adisplaymode = Display.getAvailableDisplayModes();
List list = new ArrayList();
for (int i = 0; i < adisplaymode.length; ++i)
{
DisplayMode displaymode = adisplaymode[i];
if (desktopDisplayMode == null || displaymode.getBitsPerPixel() == desktopDisplayMode.getBitsPerPixel() && displaymode.getFrequency() == desktopDisplayMode.getFrequency())
{
list.add(displaymode);
}
}
DisplayMode[] adisplaymode1 = (DisplayMode[])((DisplayMode[])list.toArray(new DisplayMode[list.size()]));
Comparator comparator = new Comparator()
{
public int compare(Object p_compare_1_, Object p_compare_2_)
{
DisplayMode displaymode1 = (DisplayMode)p_compare_1_;
DisplayMode displaymode2 = (DisplayMode)p_compare_2_;
return displaymode1.getWidth() != displaymode2.getWidth() ? displaymode2.getWidth() - displaymode1.getWidth() : (displaymode1.getHeight() != displaymode2.getHeight() ? displaymode2.getHeight() - displaymode1.getHeight() : 0);
}
};
Arrays.sort(adisplaymode1, comparator);
return adisplaymode1;
}
catch (Exception exception)
{
exception.printStackTrace();
return new DisplayMode[] {desktopDisplayMode};
}
}
示例15: getFullscreenModes
import org.lwjgl.opengl.DisplayMode; //導入方法依賴的package包/類
public static String[] getFullscreenModes()
{
DisplayMode[] adisplaymode = getFullscreenDisplayModes();
String[] astring = new String[adisplaymode.length];
for (int i = 0; i < adisplaymode.length; ++i)
{
DisplayMode displaymode = adisplaymode[i];
String s = "" + displaymode.getWidth() + "x" + displaymode.getHeight();
astring[i] = s;
}
return astring;
}