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


Java GLFWWindowSizeCallback类代码示例

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


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

示例1: setCallbacks

import org.lwjgl.glfw.GLFWWindowSizeCallback; //导入依赖的package包/类
public static void setCallbacks()
{
    keyCallback = new Input.KeyCallback();
    charCallback = new Input.CharCallback();
    mouseCallback = new Input.MouseCallback();
    motionCallback = new Input.MotionCallback();
    resizeCallback = new GLFWWindowSizeCallback()
    {
        @Override
        public void invoke(long window, int width, int height)
        {
            if (!fullscreen)
            {
                size.x = width;
                size.y = height;
            }
        }
    };

    Lime.LOGGER.F("Setting callbacks");
    glfwSetKeyCallback(windowHandle, keyCallback);
    glfwSetCharCallback(windowHandle, charCallback);
    glfwSetMouseButtonCallback(windowHandle, mouseCallback);
    glfwSetCursorPosCallback(windowHandle, motionCallback);
    glfwSetWindowSizeCallback(windowHandle, resizeCallback);
    Lime.LOGGER.F("Callbacks set");
}
 
开发者ID:LoDoMa,项目名称:Lime,代码行数:28,代码来源:Window.java

示例2: CreateWindow

import org.lwjgl.glfw.GLFWWindowSizeCallback; //导入依赖的package包/类
public static void CreateWindow(int width, int height, String title)
{
	try 
	{
		if(!glfwInit()) throw new Exception("GLFW Initialization failed.");
		glfwSetErrorCallback(m_errorCallback = GLFWErrorCallback.createPrint(System.err));
		glfwDefaultWindowHints();
		glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
		glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
		glfwWindowHint(GLFW_REFRESH_RATE , GLFW_DONT_CARE);
		glfwWindowHint(GLFW_DOUBLEBUFFER , GL_TRUE);
		Window.WIDTH = width;
		Window.HEIGHT = height;
		m_window = glfwCreateWindow(width, height, title, NULL, NULL);
		if(m_window == 0) throw new Exception("GLFW Window creation failed.");
		GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
		// Center our window
		glfwSetWindowPos(
			m_window,
			(vidmode.width() - WIDTH) / 2,
			(vidmode.height() - HEIGHT) / 2
		);
		
		Mouse = window.new Mouse();
		Mouse.Create(m_window);

		glfwSetWindowSizeCallback(m_window, m_resizeCallBack = new GLFWWindowSizeCallback()
		{
			@Override
			public void invoke(long arg0, int arg1, int arg2)
			{
				Window.WIDTH = arg1;
				Window.HEIGHT = arg2;
			}
		});
		glfwMakeContextCurrent(m_window);
		glfwSwapInterval(0);
		glfwShowWindow(m_window);
		GL.createCapabilities();
		int vao = GL30.glGenVertexArrays ();
		GL30.glBindVertexArray (vao);
	} 
	catch (Exception e) 
	{
		e.printStackTrace();
		System.exit(0);
	}
}
 
开发者ID:RagnarrIvarssen,项目名称:Assimp-Tutorial-LWJGL-3,代码行数:49,代码来源:Window.java

示例3: init

import org.lwjgl.glfw.GLFWWindowSizeCallback; //导入依赖的package包/类
private void init()
{
    // Setup an error callback. The default implementation
    // will print the error message in System.err.
    glfwSetErrorCallback(this.errorCallback = errorCallbackPrint(System.err));

    // Initialize GLFW. Most GLFW functions will not work before doing this.
    if (glfwInit() != GL11.GL_TRUE)
    {
        throw new IllegalStateException("Unable to initialize GLFW");
    }

    // Configure our window
    glfwDefaultWindowHints(); // optional, the current window hints are already the default
    glfwWindowHint(GLFW_VISIBLE, GL_FALSE); // the window will stay hidden after creation
    glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); // the window will be resizable

    // Create the window
    this.window = glfwCreateWindow(this.width, this.height, "DioritOS", NULL, NULL);
    if (this.window == NULL)
    {
        throw new RuntimeException("Failed to create the GLFW window");
    }
    this.resizeCallback = GLFWWindowSizeCallback(this::handleResize);

    // Setup a key callback. It will be called every time a key is pressed, repeated or released.
    glfwSetKeyCallback(this.window, this.keyCallback = new MyGLFWResizeKeyCallback());

    // Get the resolution of the primary monitor
    final ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
    // Center our window
    glfwSetWindowPos(this.window, (GLFWvidmode.width(vidmode) - this.width) / 2, (GLFWvidmode.height(vidmode) - this.height) / 2);

    // Make the OpenGL context current
    glfwMakeContextCurrent(this.window);
    // Enable v-sync
    glfwSwapInterval(1);

    // Make the window visible
    glfwShowWindow(this.window);

    glfwSetWindowSizeCallback(this.window, this.resizeCallback);
}
 
开发者ID:Diorite,项目名称:Diorite-old,代码行数:44,代码来源:Main.java

示例4: init

import org.lwjgl.glfw.GLFWWindowSizeCallback; //导入依赖的package包/类
public void init() {
	ar = Aargon.getInstance();
	graphicsThread = ar.getThreadPool().submit(() -> {
		try {
			errorCb = GLFWErrorCallback.createPrint();
			GLFW.glfwSetErrorCallback(errorCb);

			if (GLFW.glfwInit() != GLFW.GLFW_TRUE)
				throw new IllegalStateException("Could not initialize GLFW!");

			GLFW.glfwDefaultWindowHints();
			GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE);
			GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GLFW.GLFW_FALSE);

			winId = GLFW.glfwCreateWindow(DEF_WIDTH, DEF_HEIGHT, "OpenAargon", MemoryUtil.NULL, MemoryUtil.NULL);
			if (winId == MemoryUtil.NULL)
				throw new IllegalStateException("Could not initialize window!");

			GLFW.glfwSetKeyCallback(winId, ar.getInputManager().getKeyCallback());
			GLFW.glfwSetMouseButtonCallback(winId, ar.getInputManager().getMouseCallback());
			GLFW.glfwSetCursorPosCallback(winId, ar.getInputManager().getCursorCallback());
			windowSizeCb = new GLFWWindowSizeCallback() {
				@Override
				public void invoke(long id, int w, int h) {
					windowSize.setX(w).setY(h);
					windowResized.set(true);
				}
			};
			GLFW.glfwSetWindowSizeCallback(winId, windowSizeCb);

			GLFWVidMode vidMode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
			GLFW.glfwSetWindowPos(winId, (vidMode.width() - DEF_WIDTH) / 2, (vidMode.height() - DEF_HEIGHT) / 2);

			GLFW.glfwMakeContextCurrent(winId);
			GLFW.glfwSwapInterval(1);

			GL.createCapabilities();

			vaoId = GL30.glGenVertexArrays();
			GL30.glBindVertexArray(vaoId);
			vboId = GL15.glGenBuffers();
			GL30.glBindVertexArray(0);

			initShaders();
			GL11.glClearColor(0F, 0F, 0F, 1F);
			GL11.glEnable(GL11.GL_BLEND);
			GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
			GL11.glEnable(GL11.GL_LINE_SMOOTH);
			GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);

			GL11.glViewport(0, 0, windowSize.getX(), windowSize.getY());

			while (GLFW.glfwWindowShouldClose(winId) == GLFW.GLFW_FALSE) {
				if (windowResized.getAndSet(false))
					GL11.glViewport(0, 0, windowSize.getX(), windowSize.getY());

				GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

				ar.bufferRenders(WORLD_WIDTH, WORLD_HEIGHT, (float)windowSize.getX() / (float)windowSize.getY());

				render();
				GLFW.glfwSwapBuffers(winId);

				GLFW.glfwPollEvents();
			}
		} catch (Exception e) {
			Aargon.getLogger().error("Graphics thread errored!");
			e.printStackTrace();
		} finally {
			destruct();
			new Thread(Main::exitRequested, "Exit Thread").run();
		}
	});
}
 
开发者ID:phantamanta44,项目名称:OpenAargon,代码行数:75,代码来源:GameWindow.java

示例5: finishInitialization

import org.lwjgl.glfw.GLFWWindowSizeCallback; //导入依赖的package包/类
@RequiresNonNull("this.mav")
@EnsuresNonNull("this.canvas")
@UIEffect
private void finishInitialization(boolean es) {
	GLFWErrorCallback ecb = GLFWErrorCallback.createPrint(System.err);
	mav.keepAlive(ecb);
	glfwSetErrorCallback(ecb);
	
	GLFWWindowSizeCallback scb = GLFWWindowSizeCallback.create(this::updateWindowSize);
	mav.keepAlive(scb);
	glfwSetWindowSizeCallback(window, scb);
	
	updateWindowSize(window, DEFAULT_WIDTH, DEFAULT_HEIGHT);
	
	String version = getGLVersion(es);
	int major = version.charAt(0)-'0';
	int minor = version.charAt(2)-'0';
	
	if (es) {
		if (major >= 3) {
			log.info("Using OpenGL ES 3 rendering");
			canvas = new NanoVGGLES3Canvas(mav);
		} else if (major >= 2) {
			log.info("Using OpenGL ES 2 rendering");
			canvas = new NanoVGGLES2Canvas(mav);
		} else {
			throw new Panic("panic.noSuitableContext", I18n.get("panic.noSuitableContext.onlyGlEs", version));
		}
	} else {
		if (major >= 3) {
			log.info("Using OpenGL 3 rendering");
			canvas = new NanoVGGL3Canvas(mav);
		} else if (major >= 2) {
			log.info("Using OpenGL 2 rendering");
			canvas = new NanoVGGL2Canvas(mav);
		} else {
			throw new Panic("panic.noSuitableContext", I18n.get("panic.noSuitableContext.onlyGl", version));
		}
	}
	
	glfwShowWindow(window);
	
	if (glfwExtensionSupported("WGL_EXT_swap_control_tear") || glfwExtensionSupported("GLX_EXT_swap_control_tear")) {
		log.info("Using tearing prevention");
		glfwSwapInterval(-1);
	} else {
		glfwSwapInterval(1);
	}
}
 
开发者ID:mav-assistant,项目名称:Mavkit,代码行数:50,代码来源:Display.java

示例6: getWindowSizeCallback

import org.lwjgl.glfw.GLFWWindowSizeCallback; //导入依赖的package包/类
/**
 * Gets the GLFWWindow's Window Size Callback
 * 
 * @return Window Size Callback of the GLFW Instance
 */
public GLFWWindowSizeCallback getWindowSizeCallback() {
	return windowSizeCallback;
}
 
开发者ID:nickclark2016,项目名称:JavaGraphicsEngine,代码行数:9,代码来源:Window.java

示例7: setWindowSizeCallback

import org.lwjgl.glfw.GLFWWindowSizeCallback; //导入依赖的package包/类
/**
 * Sets the GLFWWindow's Window Size Callback
 * 
 * @param windowSizeCallback	GLFWWindowSizeCallback to be used by the GLFW Instance
 */
public void setWindowSizeCallback(GLFWWindowSizeCallback windowSizeCallback) {
	this.windowSizeCallback = windowSizeCallback;
}
 
开发者ID:nickclark2016,项目名称:JavaGraphicsEngine,代码行数:9,代码来源:Window.java


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