Java Code Examples for org.lwjgl.glfw.GLFW#glfwGetWindowSize()

The following examples show how to use org.lwjgl.glfw.GLFW#glfwGetWindowSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Lwjgl3Mini2DxGraphics.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
void updateFramebufferInfo() {
	GLFW.glfwGetFramebufferSize(window.getWindowHandle(), tmpBuffer, tmpBuffer2);
	this.backBufferWidth = tmpBuffer.get(0);
	this.backBufferHeight = tmpBuffer2.get(0);
	GLFW.glfwGetWindowSize(window.getWindowHandle(), tmpBuffer, tmpBuffer2);
	Lwjgl3Mini2DxGraphics.this.logicalWidth = tmpBuffer.get(0);
	Lwjgl3Mini2DxGraphics.this.logicalHeight = tmpBuffer2.get(0);
	Lwjgl3ApplicationConfiguration config = window.getConfig();
	bufferFormat = new BufferFormat(config.r, config.g, config.b, config.a, config.depth, config.stencil,
			config.samples, false);
}
 
Example 2
Source File: Lwjgl3Mini2DxGraphics.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
@Override
public Monitor getMonitor() {
	Monitor[] monitors = getMonitors();
	Monitor result = monitors[0];

	GLFW.glfwGetWindowPos(window.getWindowHandle(), tmpBuffer, tmpBuffer2);
	int windowX = tmpBuffer.get(0);
	int windowY = tmpBuffer2.get(0);
	GLFW.glfwGetWindowSize(window.getWindowHandle(), tmpBuffer, tmpBuffer2);
	int windowWidth = tmpBuffer.get(0);
	int windowHeight = tmpBuffer2.get(0);
	int overlap;
	int bestOverlap = 0;

	for (Monitor monitor : monitors) {
		DisplayMode mode = getDisplayMode(monitor);

		overlap = Math.max(0,
				Math.min(windowX + windowWidth, monitor.virtualX + mode.width)
						- Math.max(windowX, monitor.virtualX))
				* Math.max(0, Math.min(windowY + windowHeight, monitor.virtualY + mode.height)
				- Math.max(windowY, monitor.virtualY));

		if (bestOverlap < overlap) {
			bestOverlap = overlap;
			result = monitor;
		}
	}
	return result;
}