當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。