Search in sources :

Example 1 with GLFW_TRUE

use of org.lwjgl.glfw.GLFW.GLFW_TRUE in project legui by SpinyOwl.

the class Demo method initialize.

private void initialize() {
    if (!GLFW.glfwInit()) {
        throw new RuntimeException("Can't initialize GLFW");
    }
    ChainErrorCallback errorCallback = new ChainErrorCallback();
    errorCallback.add(GLFWErrorCallback.createPrint(System.err));
    errorCallback.add(GLFWErrorCallback.createThrow());
    glfwSetErrorCallback(errorCallback);
    glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE);
    GLFWKeyCallbackI glfwKeyCallbackI = (w1, key, code, action, mods) -> running = !(key == GLFW_KEY_ESCAPE && action != GLFW_RELEASE);
    GLFWWindowCloseCallbackI glfwWindowCloseCallbackI = w -> running = false;
    frame = new Frame(width, height);
    window = glfwCreateWindow(width, height, title, NULL, NULL);
    glfwSetWindowPos(window, 50, 50);
    glfwShowWindow(window);
    createGuiElements(frame);
    context = new Context(window);
    keeper = new DefaultCallbackKeeper();
    CallbackKeeper.registerCallbacks(window, keeper);
    keeper.getChainKeyCallback().add(glfwKeyCallbackI);
    keeper.getChainWindowCloseCallback().add(glfwWindowCloseCallbackI);
    systemEventProcessor = new SystemEventProcessorImpl();
    SystemEventProcessor.addDefaultCallbacks(keeper, systemEventProcessor);
    running = true;
}
Also used : ChainErrorCallback(com.spinyowl.cbchain.impl.ChainErrorCallback) GLFW.glfwDestroyWindow(org.lwjgl.glfw.GLFW.glfwDestroyWindow) GLFW.glfwSwapBuffers(org.lwjgl.glfw.GLFW.glfwSwapBuffers) GLFW_RELEASE(org.lwjgl.glfw.GLFW.GLFW_RELEASE) GL.setCapabilities(org.lwjgl.opengl.GL.setCapabilities) GLFW.glfwCreateWindow(org.lwjgl.glfw.GLFW.glfwCreateWindow) GLFWErrorCallback(org.lwjgl.glfw.GLFWErrorCallback) GLFW.glfwSwapInterval(org.lwjgl.glfw.GLFW.glfwSwapInterval) GLFW.glfwWindowHint(org.lwjgl.glfw.GLFW.glfwWindowHint) ChainErrorCallback(com.spinyowl.cbchain.impl.ChainErrorCallback) GL11.glViewport(org.lwjgl.opengl.GL11.glViewport) EventProcessor(com.spinyowl.legui.listener.processor.EventProcessor) NULL(org.lwjgl.system.MemoryUtil.NULL) GL_COLOR_BUFFER_BIT(org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT) Renderer(com.spinyowl.legui.system.renderer.Renderer) GLFW.glfwSetErrorCallback(org.lwjgl.glfw.GLFW.glfwSetErrorCallback) GLFWWindowCloseCallbackI(org.lwjgl.glfw.GLFWWindowCloseCallbackI) CallbackKeeper(com.spinyowl.legui.system.context.CallbackKeeper) GLFW_TRUE(org.lwjgl.glfw.GLFW.GLFW_TRUE) GL.createCapabilities(org.lwjgl.opengl.GL.createCapabilities) GL11.glClear(org.lwjgl.opengl.GL11.glClear) GLFW.glfwShowWindow(org.lwjgl.glfw.GLFW.glfwShowWindow) LayoutManager(com.spinyowl.legui.system.layout.LayoutManager) NvgRenderer(com.spinyowl.legui.system.renderer.nvg.NvgRenderer) GLFW_DOUBLEBUFFER(org.lwjgl.glfw.GLFW.GLFW_DOUBLEBUFFER) GL_STENCIL_BUFFER_BIT(org.lwjgl.opengl.GL11.GL_STENCIL_BUFFER_BIT) Context(com.spinyowl.legui.system.context.Context) Frame(com.spinyowl.legui.component.Frame) SystemEventProcessorImpl(com.spinyowl.legui.system.handler.processor.SystemEventProcessorImpl) GLFW.glfwTerminate(org.lwjgl.glfw.GLFW.glfwTerminate) GLFWKeyCallbackI(org.lwjgl.glfw.GLFWKeyCallbackI) GL11.glClearColor(org.lwjgl.opengl.GL11.glClearColor) DefaultCallbackKeeper(com.spinyowl.legui.system.context.DefaultCallbackKeeper) GLFW.glfwSetWindowPos(org.lwjgl.glfw.GLFW.glfwSetWindowPos) GLFW(org.lwjgl.glfw.GLFW) GLFW.glfwWaitEvents(org.lwjgl.glfw.GLFW.glfwWaitEvents) AnimatorProvider(com.spinyowl.legui.animation.AnimatorProvider) GLFW.glfwMakeContextCurrent(org.lwjgl.glfw.GLFW.glfwMakeContextCurrent) TimeUnit(java.util.concurrent.TimeUnit) SystemEventProcessor(com.spinyowl.legui.system.handler.processor.SystemEventProcessor) EventProcessorProvider(com.spinyowl.legui.listener.processor.EventProcessorProvider) GLCapabilities(org.lwjgl.opengl.GLCapabilities) Vector2i(org.joml.Vector2i) GLFW_KEY_ESCAPE(org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) Context(com.spinyowl.legui.system.context.Context) GLFWKeyCallbackI(org.lwjgl.glfw.GLFWKeyCallbackI) Frame(com.spinyowl.legui.component.Frame) GLFWWindowCloseCallbackI(org.lwjgl.glfw.GLFWWindowCloseCallbackI) DefaultCallbackKeeper(com.spinyowl.legui.system.context.DefaultCallbackKeeper) SystemEventProcessorImpl(com.spinyowl.legui.system.handler.processor.SystemEventProcessorImpl)

Aggregations

ChainErrorCallback (com.spinyowl.cbchain.impl.ChainErrorCallback)1 AnimatorProvider (com.spinyowl.legui.animation.AnimatorProvider)1 Frame (com.spinyowl.legui.component.Frame)1 EventProcessor (com.spinyowl.legui.listener.processor.EventProcessor)1 EventProcessorProvider (com.spinyowl.legui.listener.processor.EventProcessorProvider)1 CallbackKeeper (com.spinyowl.legui.system.context.CallbackKeeper)1 Context (com.spinyowl.legui.system.context.Context)1 DefaultCallbackKeeper (com.spinyowl.legui.system.context.DefaultCallbackKeeper)1 SystemEventProcessor (com.spinyowl.legui.system.handler.processor.SystemEventProcessor)1 SystemEventProcessorImpl (com.spinyowl.legui.system.handler.processor.SystemEventProcessorImpl)1 LayoutManager (com.spinyowl.legui.system.layout.LayoutManager)1 Renderer (com.spinyowl.legui.system.renderer.Renderer)1 NvgRenderer (com.spinyowl.legui.system.renderer.nvg.NvgRenderer)1 TimeUnit (java.util.concurrent.TimeUnit)1 Vector2i (org.joml.Vector2i)1 GLFW (org.lwjgl.glfw.GLFW)1 GLFW_DOUBLEBUFFER (org.lwjgl.glfw.GLFW.GLFW_DOUBLEBUFFER)1 GLFW_KEY_ESCAPE (org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE)1 GLFW_RELEASE (org.lwjgl.glfw.GLFW.GLFW_RELEASE)1 GLFW_TRUE (org.lwjgl.glfw.GLFW.GLFW_TRUE)1