org.lwjgl.glfw.GLFW Java Examples
The following examples show how to use
org.lwjgl.glfw.GLFW.
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 | 6 votes |
@Override public boolean setWindowedMode(int width, int height) { window.getInput().resetPollingStates(); if (!isFullscreen()) { GLFW.glfwSetWindowSize(window.getWindowHandle(), width, height); } else { if (displayModeBeforeFullscreen == null) { storeCurrentWindowPositionAndDisplayMode(); } GLFW.glfwSetWindowMonitor(window.getWindowHandle(), 0, windowPosXBeforeFullscreen, windowPosYBeforeFullscreen, width, height, displayModeBeforeFullscreen.refreshRate); } updateFramebufferInfo(); return true; }
Example #2
Source File: GuiSprint.java From Better-Sprinting with Mozilla Public License 2.0 | 6 votes |
@Override public boolean keyPressed(int keyCode, int scanCode, int modifiers){ if (selectedBinding != null){ if (keyCode == GLFW.GLFW_KEY_ESCAPE){ selectedBinding.setBinding(KeyModifier.NONE, InputMappings.INPUT_INVALID); } else{ selectedBinding.setBinding(KeyModifier.getActiveModifier(), InputMappings.getInputByCode(keyCode, scanCode)); } onSelectedBindingUpdated(); return true; } else{ return super.keyPressed(keyCode, scanCode, modifiers); } }
Example #3
Source File: Lwjgl3Mini2DxWindow.java From mini2Dx with Apache License 2.0 | 6 votes |
@Override public void dispose() { listener.pause(); listener.dispose(); Lwjgl3Mini2DxCursor.dispose(this); graphics.dispose(); input.dispose(); GLFW.glfwSetWindowFocusCallback(windowHandle, null); GLFW.glfwSetWindowIconifyCallback(windowHandle, null); GLFW.glfwSetWindowCloseCallback(windowHandle, null); GLFW.glfwSetDropCallback(windowHandle, null); GLFW.glfwDestroyWindow(windowHandle); focusCallback.free(); iconifyCallback.free(); maximizeCallback.free(); closeCallback.free(); dropCallback.free(); refreshCallback.free(); }
Example #4
Source File: EnterProfileNameScreen.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
@Override public boolean keyPressed(int keyCode, int scanCode, int int_3) { switch(keyCode) { case GLFW.GLFW_KEY_ENTER: done(); break; case GLFW.GLFW_KEY_ESCAPE: client.openScreen(prevScreen); break; } return super.keyPressed(keyCode, scanCode, int_3); }
Example #5
Source File: CottonInventoryScreen.java From LibGui with MIT License | 6 votes |
@Override public boolean keyPressed(int ch, int keyCode, int modifiers) { //System.out.println("Key " + Integer.toHexString(ch)+" "+Integer.toHexString(keyCode)); if (ch==GLFW.GLFW_KEY_ESCAPE) { this.client.player.closeHandledScreen(); return true; } else if (ch==GLFW.GLFW_KEY_TAB) { changeFocus(!hasShiftDown()); return true; } else { //if (super.keyPressed(ch, keyCode, modifiers)) return true; if (description.getFocus()==null) { if (MinecraftClient.getInstance().options.keyInventory.matchesKey(ch, keyCode)) { this.client.player.closeHandledScreen(); return true; } return false; } else { description.getFocus().onKeyPressed(ch, keyCode, modifiers); return true; } } }
Example #6
Source File: Lwjgl3Mini2DxInput.java From mini2Dx with Apache License 2.0 | 6 votes |
@Override public void invoke(long window, int button, int action, int mods) { int gdxButton = toGdxButton(button); if (button != -1 && gdxButton == -1) return; if (action == GLFW.GLFW_PRESS) { mousePressed++; justTouched = true; justPressedButtons[gdxButton] = true; Lwjgl3Mini2DxInput.this.window.getGraphics().requestRendering(); eventQueue.touchDown(mouseX, mouseY, 0, gdxButton); } else { mousePressed = Math.max(0, mousePressed - 1); Lwjgl3Mini2DxInput.this.window.getGraphics().requestRendering(); eventQueue.touchUp(mouseX, mouseY, 0, gdxButton); } }
Example #7
Source File: Window.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public void update() { if (isResized) { GL11.glViewport(0, 0, width, height); isResized = false; } GL11.glClearColor(background.getX(), background.getY(), background.getZ(), 1.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GLFW.glfwPollEvents(); frames++; if (System.currentTimeMillis() > time + 1000) { GLFW.glfwSetWindowTitle(window, title + " | FPS: " + frames); time = System.currentTimeMillis(); frames = 0; } }
Example #8
Source File: Lwjgl3Mini2DxInput.java From mini2Dx with Apache License 2.0 | 5 votes |
@Override public boolean isKeyPressed(int key) { if (key == Input.Keys.ANY_KEY) return pressedKeys > 0; if (key == Input.Keys.SYM) { return GLFW.glfwGetKey(window.getWindowHandle(), GLFW.GLFW_KEY_LEFT_SUPER) == GLFW.GLFW_PRESS|| GLFW.glfwGetKey(window.getWindowHandle(), GLFW.GLFW_KEY_RIGHT_SUPER) == GLFW.GLFW_PRESS; } return GLFW.glfwGetKey(window.getWindowHandle(), getGlfwKeyCode(key)) == GLFW.GLFW_PRESS; }
Example #9
Source File: ServerFinderScreen.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Override public boolean keyPressed(int keyCode, int scanCode, int int_3) { if(keyCode == GLFW.GLFW_KEY_ENTER) searchButton.onPress(); return super.keyPressed(keyCode, scanCode, int_3); }
Example #10
Source File: KeyboardKeyCallback.java From LWJGUI with MIT License | 5 votes |
@Override public void invoke(long window, int key, int scancode, int action, int mods) { if (key < 0 || key > 65535) { System.out.println("WARNING: Caught invalid key! (Key: " + key + ", scancode: " + scancode + ", pressed: " + (action != GLFW.GLFW_RELEASE) + ")"); return; } this.keys.set(key, (action != GLFW.GLFW_RELEASE)); if (action == GLFW.GLFW_RELEASE && this.ignore.get(key)) this.ignore.clear(key); }
Example #11
Source File: EntityControl.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public EntityControl() { super("EntityControl", GLFW.GLFW_KEY_GRAVE_ACCENT, Category.MOVEMENT, "Manipulate Entities.", new SettingToggle("EntitySpeed", true), new SettingSlider("Speed: ", 0, 5, 1.2, 2), new SettingToggle("EntityFly", false), new SettingToggle("Ground Snap", false), new SettingToggle("AntiStuck", false)); }
Example #12
Source File: TextInputControl.java From LWJGUI with MIT License | 5 votes |
public void paste() { saveState(); deleteSelection(); WindowManager.runLater(()-> { String str = GLFW.glfwGetClipboardString(window.getID()); insertText(caretPosition, str); caretPosition += str.length(); }); }
Example #13
Source File: LwjglContextVR.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected int determineMaxSamples() { // If we already have a valid context, determine samples using current context. logger.log(Level.SEVERE, "glfwExtensionSupported(\"GL_ARB_framebuffer_object\"): "+GLFW.glfwExtensionSupported("GL_ARB_framebuffer_object")); logger.log(Level.SEVERE, "glfwExtensionSupported(\"GL_EXT_framebuffer_multisample\"): "+GLFW.glfwExtensionSupported("GL_ARB_framebuffer_object")); if (GLFW.glfwExtensionSupported("GL_ARB_framebuffer_object")) { return glGetInteger(ARBFramebufferObject.GL_MAX_SAMPLES); } else if (GLFW.glfwExtensionSupported("GL_EXT_framebuffer_multisample")) { return glGetInteger(EXTFramebufferMultisample.GL_MAX_SAMPLES_EXT); } return Integer.MAX_VALUE; }
Example #14
Source File: LWJGUIUtil.java From LWJGUI with MIT License | 5 votes |
private static void hints(boolean modernOpenGL) { if ( modernOpenGL ) { glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); } else { glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_ANY_PROFILE); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); } }
Example #15
Source File: Window.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public void setFullscreen(boolean isFullscreen) { this.isFullscreen = isFullscreen; isResized = true; if (isFullscreen) { GLFW.glfwGetWindowPos(window, windowPosX, windowPosY); GLFW.glfwSetWindowMonitor(window, GLFW.glfwGetPrimaryMonitor(), 0, 0, width, height, 0); } else { GLFW.glfwSetWindowMonitor(window, 0, windowPosX[0], windowPosY[0], width, height, 0); } }
Example #16
Source File: DesktopMini2DxGame.java From mini2Dx with Apache License 2.0 | 5 votes |
static void initializeGlfw() { if (errorCallback == null) { Lwjgl3NativesLoader.load(); errorCallback = GLFWErrorCallback.createPrint(System.err); GLFW.glfwSetErrorCallback(errorCallback); GLFW.glfwInitHint(GLFW.GLFW_JOYSTICK_HAT_BUTTONS, GLFW.GLFW_FALSE); if (!GLFW.glfwInit()) { throw new GdxRuntimeException("Unable to initialize GLFW"); } } }
Example #17
Source File: Lwjgl3Mini2DxCursor.java From mini2Dx with Apache License 2.0 | 5 votes |
Lwjgl3Mini2DxCursor(Lwjgl3Mini2DxWindow window, Pixmap pixmap, int xHotspot, int yHotspot) { this.window = window; if (pixmap.getFormat() != Pixmap.Format.RGBA8888) { throw new GdxRuntimeException("Cursor image pixmap is not in RGBA8888 format."); } if ((pixmap.getWidth() & (pixmap.getWidth() - 1)) != 0) { throw new GdxRuntimeException( "Cursor image pixmap width of " + pixmap.getWidth() + " is not a power-of-two greater than zero."); } if ((pixmap.getHeight() & (pixmap.getHeight() - 1)) != 0) { throw new GdxRuntimeException("Cursor image pixmap height of " + pixmap.getHeight() + " is not a power-of-two greater than zero."); } if (xHotspot < 0 || xHotspot >= pixmap.getWidth()) { throw new GdxRuntimeException("xHotspot coordinate of " + xHotspot + " is not within image width bounds: [0, " + pixmap.getWidth() + ")."); } if (yHotspot < 0 || yHotspot >= pixmap.getHeight()) { throw new GdxRuntimeException("yHotspot coordinate of " + yHotspot + " is not within image height bounds: [0, " + pixmap.getHeight() + ")."); } this.pixmapCopy = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), Pixmap.Format.RGBA8888); this.pixmapCopy.setBlending(Pixmap.Blending.None); this.pixmapCopy.drawPixmap(pixmap, 0, 0); glfwImage = GLFWImage.malloc(); glfwImage.width(pixmapCopy.getWidth()); glfwImage.height(pixmapCopy.getHeight()); glfwImage.pixels(pixmapCopy.getPixels()); glfwCursor = GLFW.glfwCreateCursor(glfwImage, xHotspot, yHotspot); cursors.add(this); }
Example #18
Source File: PacketFly.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public PacketFly() { super("PacketFly", GLFW.GLFW_KEY_H, Category.MOVEMENT, "Allows you to fly with packets.", new SettingMode("Mode: ", "Phase", "Packet"), new SettingSlider("HSpeed: ", 0.05, 2, 0.5, 2), new SettingSlider("VSpeed: ", 0.05, 2, 0.5, 2), new SettingSlider("Fall: ", 0, 40, 20, 0), new SettingToggle("Packet Cancel", false)); }
Example #19
Source File: EntityControl.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public EntityControl() { super("EntityControl", GLFW.GLFW_KEY_GRAVE_ACCENT, Category.MOVEMENT, "Manipulate Entities.", new SettingToggle("EntitySpeed", true), new SettingSlider("Speed: ", 0, 5, 1.2, 2), new SettingToggle("EntityFly", false), new SettingToggle("Ground Snap", false), new SettingToggle("AntiStuck", false)); }
Example #20
Source File: Lwjgl3Mini2DxCursor.java From mini2Dx with Apache License 2.0 | 5 votes |
@Override public void dispose() { if (pixmapCopy == null) { throw new GdxRuntimeException("Cursor already disposed"); } cursors.removeValue(this, true); pixmapCopy.dispose(); pixmapCopy = null; glfwImage.free(); GLFW.glfwDestroyCursor(glfwCursor); }
Example #21
Source File: GLFWContextCreator.java From settlers-remake with MIT License | 5 votes |
@Override public void invoke(long window, double xpos, double ypos) { last_point = new UIPoint(xpos, height - ypos); updateHoverPosition(last_point); if(presstime+0.1<GLFW.glfwGetTime()) { updatePanPosition(last_point); updateDrawPosition(last_point); } }
Example #22
Source File: Lwjgl3Mini2DxGraphics.java From mini2Dx with Apache License 2.0 | 5 votes |
@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; }
Example #23
Source File: Lwjgl3Mini2DxInput.java From mini2Dx with Apache License 2.0 | 5 votes |
@Override public boolean isTouched() { return GLFW.glfwGetMouseButton(window.getWindowHandle(), GLFW.GLFW_MOUSE_BUTTON_1) == GLFW.GLFW_PRESS || GLFW.glfwGetMouseButton(window.getWindowHandle(), GLFW.GLFW_MOUSE_BUTTON_2) == GLFW.GLFW_PRESS || GLFW.glfwGetMouseButton(window.getWindowHandle(), GLFW.GLFW_MOUSE_BUTTON_3) == GLFW.GLFW_PRESS || GLFW.glfwGetMouseButton(window.getWindowHandle(), GLFW.GLFW_MOUSE_BUTTON_4) == GLFW.GLFW_PRESS || GLFW.glfwGetMouseButton(window.getWindowHandle(), GLFW.GLFW_MOUSE_BUTTON_5) == GLFW.GLFW_PRESS; }
Example #24
Source File: WindowHandle.java From LWJGUI with MIT License | 5 votes |
protected void applyHints() { GLFW.glfwDefaultWindowHints(); hints.forEach((key, value) -> { GLFW.glfwWindowHint(key, value); }); hints.clear(); }
Example #25
Source File: Killaura.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public Killaura() { super("Killaura", GLFW.GLFW_KEY_K, Category.COMBAT, "Automatically attacks entities", new SettingToggle("Players", true), new SettingToggle("Mobs", true), new SettingToggle("Animals", false), new SettingToggle("Armor Stands", false), new SettingToggle("Aimbot", true), new SettingToggle("Thru Walls", false), new SettingToggle("1.9 Delay", false), new SettingSlider("Range: ", 0, 6, 4.25, 2), new SettingSlider("CPS: ", 0, 20, 8, 0)); }
Example #26
Source File: GLFWContextCreator.java From settlers-remake with MIT License | 5 votes |
private void registerCallbacks() { GLFW.glfwSetKeyCallback(glfw_wnd, key_callback); GLFW.glfwSetMouseButtonCallback(glfw_wnd, mouse_callback); GLFW.glfwSetScrollCallback(glfw_wnd, scroll_callback); GLFW.glfwSetCursorEnterCallback(glfw_wnd, cursorenter_callback); GLFW.glfwSetCursorPosCallback(glfw_wnd, cursorpos_callback); GLFW.glfwSetWindowSizeCallback(glfw_wnd, size_callback); }
Example #27
Source File: Window.java From mars-sim with GNU General Public License v3.0 | 5 votes |
private void createCallbacks() { sizeCallback = new GLFWWindowSizeCallback() { public void invoke(long window, int w, int h) { width = w; height = h; isResized = true; } }; GLFW.glfwSetKeyCallback(window, input.getKeyboardCallback()); GLFW.glfwSetCursorPosCallback(window, input.getMouseMoveCallback()); GLFW.glfwSetMouseButtonCallback(window, input.getMouseButtonsCallback()); GLFW.glfwSetScrollCallback(window, input.getMouseScrollCallback()); GLFW.glfwSetWindowSizeCallback(window, sizeCallback); }
Example #28
Source File: Lwjgl3Mini2DxGraphics.java From mini2Dx with Apache License 2.0 | 5 votes |
@Override public void invoke(long windowHandle, final int width, final int height) { updateFramebufferInfo(); if (!window.isListenerInitialized()) { return; } window.makeCurrent(); gl20.glViewport(0, 0, width, height); window.getListener().resize(getWidth(), getHeight()); window.getListener().render(); GLFW.glfwSwapBuffers(windowHandle); }
Example #29
Source File: CrystalAura.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public CrystalAura() { super("CrystalAura", GLFW.GLFW_KEY_I, Category.COMBAT, "Automatically attacks crystals for you.", new SettingToggle("Aimbot", false), new SettingToggle("Thru Walls", false), new SettingSlider("Range: ", 0, 6, 4.25, 2), new SettingSlider("CPS: ", 0, 20, 16, 0)); }
Example #30
Source File: LWJGUIUtil.java From LWJGUI with MIT License | 5 votes |
private static long createOpenGLWindow(String name, int width, int height, boolean resizable, boolean ontop, boolean modernOpenGL, boolean vsync) { // Configure GLFW glfwDefaultWindowHints(); glfwWindowHint(GLFW_VISIBLE, GL_FALSE); glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); // Hints hints(modernOpenGL); glfwWindowHint(GLFW.GLFW_FLOATING, ontop?GL_TRUE:GL_FALSE); glfwWindowHint(GLFW.GLFW_RESIZABLE, resizable?GL_TRUE:GL_FALSE); // Create the window long window = glfwCreateWindow(width, height, name, NULL, NULL); if ( window == NULL ) throw new RuntimeException("Failed to create the GLFW window"); // Finalize window glfwMakeContextCurrent(window); glfwSwapInterval(vsync ? 1 : 0); // Get the resolution of the primary monitor GLFWVidMode vidmode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor()); // Center the window GLFW.glfwSetWindowPos( window, (vidmode.width() - width) / 2, (vidmode.height() - height) / 2 ); // Create context GL.createCapabilities(); System.out.println("Creating opengl window: " + glGetString(GL_VERSION)); return window; }