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


Java GLFW.glfwCreateWindow方法代码示例

本文整理汇总了Java中org.lwjgl.glfw.GLFW.glfwCreateWindow方法的典型用法代码示例。如果您正苦于以下问题:Java GLFW.glfwCreateWindow方法的具体用法?Java GLFW.glfwCreateWindow怎么用?Java GLFW.glfwCreateWindow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.lwjgl.glfw.GLFW的用法示例。


在下文中一共展示了GLFW.glfwCreateWindow方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: create

import org.lwjgl.glfw.GLFW; //导入方法依赖的package包/类
/**
    * Creates a window width the specified width, height, and title on the specified monitor
    * @param width The width of the window
    * @param height The height of the window
    * @param title The title of the window
    * @param monitor The monitor on which to create the window
    */
   public void create(int width, int height, String title, long monitor) {
this.width = width;
this.height = height;
this.title = title;
this.monitor = monitor;

// Obtain a handle for the window
handle = GLFW.glfwCreateWindow(width, height, title, 0, MemoryUtil.NULL);
// If the window did not create properly
if(handle == 0) {
    throw new IllegalStateException("Window did not initalize");
}
   }
 
开发者ID:camilne,项目名称:open-world,代码行数:21,代码来源:Window.java

示例3: createWindow

import org.lwjgl.glfw.GLFW; //导入方法依赖的package包/类
public static Window createWindow(Scene scene, String title) {
	if (!GLFW.glfwInit()) {
		throw new IllegalStateException();
	}
	
	errorCallback = new GLFWErrorCallback() {
		public void invoke(int error, long description) {
			System.err.println("["+ error + "] " + description);
		}
	};
	GLFW.glfwSetErrorCallback(errorCallback);

	long window = GLFW.glfwCreateWindow(scene.getWidth(), scene.getHeight(), title, MemoryUtil.NULL, MemoryUtil.NULL);

	if (window == MemoryUtil.NULL) {
		System.err.println("Window returned NULL");
		System.exit(-1);
	}

	GLFW.glfwMakeContextCurrent(window);

	GLFW.glfwShowWindow(window);
	GL.createCapabilities();
	GLFW.glfwSwapInterval(1);

	scene.setGLinitilized();
	return new Window(window);
}
 
开发者ID:ComunityEngine,项目名称:CommunityEngine-Java,代码行数:29,代码来源:Window.java

示例4: createWindow

import org.lwjgl.glfw.GLFW; //导入方法依赖的package包/类
protected void createWindow()
{
	// the window will stay hidden after creation
	GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE);

	// Configure GLFW
	GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MAJOR, 3);
	GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MINOR, 2);
	GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_FORWARD_COMPAT, GLFW.GLFW_TRUE);
	GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE,
			GLFW.GLFW_OPENGL_CORE_PROFILE);

	// Create the window
	this.handle = GLFW.glfwCreateWindow(this.width, this.height, this.title,
			MemoryUtil.NULL, MemoryUtil.NULL);
	if (this.handle == MemoryUtil.NULL)
	{
		throw new RuntimeException("Failed to create the GLFW window");
	}

	//Create the input context
	//this.inputEngine = new InputEngine(this);

	//Setup a size callback.
	GLFW.glfwSetWindowSizeCallback(this.handle, (window, w, h) ->
	{
		int prevW = this.width;
		int prevH = this.height;
		this.width = w;
		this.height = h;
		this.onWindowSizeChanged.notifyListeners(new int[]{
				this.width, this.height, prevW, prevH
		});
	});

	//Setup a position callback
	GLFW.glfwSetWindowPosCallback(this.handle, (window, xpos, ypos) -> {
		int prevX = this.x;
		int prevY = this.y;
		this.x = xpos;
		this.y = ypos;
		this.onWindowPosChanged.notifyListeners(new int[]{
				this.x, this.y, prevX, prevY
		});
	});

	this.makeWindowCentered();

	// Make the OpenGL context current
	GLFW.glfwMakeContextCurrent(this.handle);

	// Enable v-sync
	GLFW.glfwSwapInterval(this.vsync ? 1 : 0);

	// This line is critical for LWJGL's interoperation with GLFW's
	// OpenGL context, or any context that is managed externally.
	// LWJGL detects the context that is current in the current thread,
	// creates the GLCapabilities instance and makes the OpenGL
	// bindings available for use.
	GL.createCapabilities();

	System.out.println("OPENGL " + GL11.glGetString(GL11.GL_VERSION));

	// Set the clear color
	GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

	//Enable depth testing
	GL11.glEnable(GL11.GL_DEPTH_TEST);

	//Set current viewport
	this.view = new View(this);
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:73,代码来源:Window.java


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