Monitor.java
com.mojang.blaze3d.platform.Monitor
信息
- 全限定名:com.mojang.blaze3d.platform.Monitor
- 类型:public final class
- 包:com.mojang.blaze3d.platform
- 源码路径:src/main/java/com/mojang/blaze3d/platform/Monitor.java
- 起始行号:L14
- 职责:
TODO
字段/常量
-
monitor- 类型:
long - 修饰符:
private final - 源码定位:
L15 - 说明:
TODO
- 类型:
-
videoModes- 类型:
List<VideoMode> - 修饰符:
private final - 源码定位:
L16 - 说明:
TODO
- 类型:
-
currentMode- 类型:
VideoMode - 修饰符:
private - 源码定位:
L17 - 说明:
TODO
- 类型:
-
x- 类型:
int - 修饰符:
private - 源码定位:
L18 - 说明:
TODO
- 类型:
-
y- 类型:
int - 修饰符:
private - 源码定位:
L19 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public Monitor(long monitor) @ L21
- 构造器名:Monitor
- 源码定位:L21
- 修饰符:public
参数:
- monitor: long
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void refreshVideoModes() @ L27
- 方法名:refreshVideoModes
- 源码定位:L27
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public VideoMode getPreferredVidMode(Optional<VideoMode> expectedMode) @ L48
- 方法名:getPreferredVidMode
- 源码定位:L48
- 返回类型:VideoMode
- 修饰符:public
参数:
- expectedMode: Optional
说明:
TODO
public int getVideoModeIndex(VideoMode videoMode) @ L62
- 方法名:getVideoModeIndex
- 源码定位:L62
- 返回类型:int
- 修饰符:public
参数:
- videoMode: VideoMode
说明:
TODO
public VideoMode getCurrentMode() @ L66
- 方法名:getCurrentMode
- 源码定位:L66
- 返回类型:VideoMode
- 修饰符:public
参数:
- 无
说明:
TODO
public int getX() @ L70
- 方法名:getX
- 源码定位:L70
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public int getY() @ L74
- 方法名:getY
- 源码定位:L74
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public VideoMode getMode(int mode) @ L78
- 方法名:getMode
- 源码定位:L78
- 返回类型:VideoMode
- 修饰符:public
参数:
- mode: int
说明:
TODO
public int getModeCount() @ L82
- 方法名:getModeCount
- 源码定位:L82
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public long getMonitor() @ L86
- 方法名:getMonitor
- 源码定位:L86
- 返回类型:long
- 修饰符:public
参数:
- 无
说明:
TODO
public String toString() @ L90
- 方法名:toString
- 源码定位:L90
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public final class Monitor {
private final long monitor;
private final List<VideoMode> videoModes;
private VideoMode currentMode;
private int x;
private int y;
public Monitor(long monitor) {
this.monitor = monitor;
this.videoModes = Lists.newArrayList();
this.refreshVideoModes();
}
public void refreshVideoModes() {
this.videoModes.clear();
Buffer modes = GLFW.glfwGetVideoModes(this.monitor);
for (int i = modes.limit() - 1; i >= 0; i--) {
modes.position(i);
VideoMode mode = new VideoMode(modes);
if (mode.getRedBits() >= 8 && mode.getGreenBits() >= 8 && mode.getBlueBits() >= 8) {
this.videoModes.add(mode);
}
}
int[] x = new int[1];
int[] y = new int[1];
GLFW.glfwGetMonitorPos(this.monitor, x, y);
this.x = x[0];
this.y = y[0];
GLFWVidMode mode = GLFW.glfwGetVideoMode(this.monitor);
this.currentMode = new VideoMode(mode);
}
public VideoMode getPreferredVidMode(Optional<VideoMode> expectedMode) {
if (expectedMode.isPresent()) {
VideoMode videoMode = expectedMode.get();
for (VideoMode mode : this.videoModes) {
if (mode.equals(videoMode)) {
return mode;
}
}
}
return this.getCurrentMode();
}
public int getVideoModeIndex(VideoMode videoMode) {
return this.videoModes.indexOf(videoMode);
}
public VideoMode getCurrentMode() {
return this.currentMode;
}
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
public VideoMode getMode(int mode) {
return this.videoModes.get(mode);
}
public int getModeCount() {
return this.videoModes.size();
}
public long getMonitor() {
return this.monitor;
}
@Override
public String toString() {
return String.format(Locale.ROOT, "Monitor[%s %sx%s %s]", this.monitor, this.x, this.y, this.currentMode);
}
}引用的其他类
- VideoMode
- 引用位置:
参数/字段/构造调用/返回值 - 关联成员:
VideoMode()
- 引用位置: