本文整理汇总了Java中org.lwjgl.glfw.GLFW.glfwGetWindowSize方法的典型用法代码示例。如果您正苦于以下问题:Java GLFW.glfwGetWindowSize方法的具体用法?Java GLFW.glfwGetWindowSize怎么用?Java GLFW.glfwGetWindowSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.glfw.GLFW
的用法示例。
在下文中一共展示了GLFW.glfwGetWindowSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeWindowCentered
import org.lwjgl.glfw.GLFW; //导入方法依赖的package包/类
public void makeWindowCentered()
{
// Get the thread stack and push a new frame
try (MemoryStack stack = MemoryStack.stackPush())
{
IntBuffer pWidth = stack.mallocInt(1); // int*
IntBuffer pHeight = stack.mallocInt(1); // int*
// Get the window size passed to glfwCreateWindow
GLFW.glfwGetWindowSize(this.handle, pWidth, pHeight);
this.width = pWidth.get(0);
this.height = pHeight.get(0);
// Get the resolution of the primary monitor
GLFWVidMode vidmode = getCurrentVideoMode();
// Center the window
GLFW.glfwSetWindowPos(
this.handle,
this.x = ((vidmode.width() - this.width) / 2),
this.y = ((vidmode.height() - this.height) / 2)
);
} // the stack frame is popped automatically
}
示例2: generate
import org.lwjgl.glfw.GLFW; //导入方法依赖的package包/类
public static Window generate(WindowHandle handle) {
long windowID = GLFW.glfwCreateWindow(handle.width, handle.height, handle.title, NULL, NULL);
if (windowID == NULL)
throw new GLFWException("Failed to create GLFW Window '" + handle.title + "'");
Window window = new Window(windowID, handle.width, handle.height);
GLFW.glfwSetWindowPos(windowID, Variables.X, Variables.Y);
int[] h = new int[1];
int[] w = new int[1];
GLFW.glfwGetFramebufferSize(windowID, w, h);
window.framebufferHeight = h[0];
window.framebufferWidth = w[0];
GLFW.glfwGetWindowSize(windowID, w, h);
window.height = h[0];
window.width = w[0];
window.pixelRatio = (float) window.framebufferWidth / (float) window.width;
return window;
}