当前位置: 首页>>代码示例>>Java>>正文


Java GLFW.glfwGetWindowSize方法代码示例

本文整理汇总了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
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:26,代码来源:Window.java

示例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;
}
 
开发者ID:Guerra24,项目名称:NanoUI,代码行数:19,代码来源:WindowManager.java


注:本文中的org.lwjgl.glfw.GLFW.glfwGetWindowSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。