Java Code Examples for org.lwjgl.input.Keyboard#KEY_1
The following examples show how to use
org.lwjgl.input.Keyboard#KEY_1 .
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: Example16_1.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void keyPressed(int key, char c) { switch(key) { case Keyboard.KEY_1: useGammaCorrect[0] = !useGammaCorrect[0]; if(useGammaCorrect[0]) System.out.println("Top:\tsRGB texture."); else System.out.println("Top:\tlinear texture."); break; case Keyboard.KEY_2: useGammaCorrect[1] = !useGammaCorrect[1]; if(useGammaCorrect[1]) System.out.println("Bottom:\tsRGB texture."); else System.out.println("Bottom:\tlinear texture."); break; } }
Example 2
Source File: GuiReactorRedstonePort.java From BigReactors with MIT License | 6 votes |
private boolean isKeyValidForValueInput(int keyCode) { if(keyCode >= Keyboard.KEY_1 && keyCode <= Keyboard.KEY_0) { return true; } switch(keyCode) { case Keyboard.KEY_NUMPAD0: case Keyboard.KEY_NUMPAD1: case Keyboard.KEY_NUMPAD2: case Keyboard.KEY_NUMPAD3: case Keyboard.KEY_NUMPAD4: case Keyboard.KEY_NUMPAD5: case Keyboard.KEY_NUMPAD6: case Keyboard.KEY_NUMPAD7: case Keyboard.KEY_NUMPAD8: case Keyboard.KEY_NUMPAD9: case Keyboard.KEY_DELETE: case Keyboard.KEY_BACK: case Keyboard.KEY_LEFT: case Keyboard.KEY_RIGHT: return true; default: return false; } }
Example 3
Source File: OpenGL3_TheQuadTextured.java From ldparteditor with MIT License | 4 votes |
private void loopCycle() { // Logic while(Keyboard.next()) { // Only listen to events where the key was pressed (down event) if (!Keyboard.getEventKeyState()) continue; // Switch textures depending on the key released switch (Keyboard.getEventKey()) { case Keyboard.KEY_1: textureSelector = 0; break; case Keyboard.KEY_2: textureSelector = 1; break; } } // Render GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GL20.glUseProgram(pId); // Bind the texture GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texIds[textureSelector]); // Bind to the VAO that has all the information about the vertices GL30.glBindVertexArray(vaoId); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); // Bind to the index VBO that has all the information about the order of the vertices GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboiId); // Draw the vertices GL11.glDrawElements(GL11.GL_TRIANGLES, indicesCount, GL11.GL_UNSIGNED_BYTE, 0); // Put everything back to default (deselect) GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); GL30.glBindVertexArray(0); GL20.glUseProgram(0); this.exitOnGLError("loopCycle"); }
Example 4
Source File: SelectionDelegate.java From tribaltrouble with GNU General Public License v2.0 | 4 votes |
public final void keyPressed(KeyboardEvent event) { getCamera().keyPressed(event); int army_number = 0; switch (event.getKeyCode()) { case Keyboard.KEY_SPACE: case Keyboard.KEY_NUMPAD5: if (!map_mode) { selection = false; getViewer().getPicker().pickRotate((GameCamera)getCamera()); map_mode = true; if (observer) observer_label.remove(); else getActionButtonPanel().remove(); getCamera().disable(); setCamera(new MapCamera(this, game_camera)); getCamera().enable(); } break; case Keyboard.KEY_TAB: if (!observer) { Notification n = getViewer().getNotificationManager().getLatestNotification(); if (n != null) { if (getCamera() instanceof GameCamera) getGUIRoot().pushDelegate(new JumpDelegate(getViewer(), (GameCamera)getCamera(), n.getX(), n.getY())); else if (getCamera() instanceof MapCamera) ((MapCamera)getCamera()).mapGoto(n.getX(), n.getY(), true); } } break; case Keyboard.KEY_9: army_number++; case Keyboard.KEY_8: army_number++; case Keyboard.KEY_7: army_number++; case Keyboard.KEY_6: army_number++; case Keyboard.KEY_5: army_number++; case Keyboard.KEY_4: army_number++; case Keyboard.KEY_3: army_number++; case Keyboard.KEY_2: army_number++; case Keyboard.KEY_1: army_number++; case Keyboard.KEY_0: if (!map_mode && !observer) { if (event.isControlDown()) { getViewer().getSelection().setShortcutArmy(army_number); } else { boolean selected = getViewer().getSelection().enableShortcutArmy(army_number); if (selected && event.getNumClicks() > 1) { Set set = getViewer().getSelection().getCurrentSelection().getSet(); if (set.size() > 0) { Selectable s = (Selectable)set.iterator().next(); getGUIRoot().pushDelegate(new JumpDelegate(getViewer(), (GameCamera)getCamera(), s.getPositionX(), s.getPositionY())); } } } } break; case Keyboard.KEY_RETURN: if (!chat_visible) chat_form.setReceivers(!event.isShiftDown()); break; case Keyboard.KEY_B: if (event.isControlDown() && !map_mode && !observer) { getGUIRoot().pushDelegate(new BeaconDelegate(getViewer(), (GameCamera)getCamera())); } break; case Keyboard.KEY_N: nextIdlePeon(); break; case Keyboard.KEY_F: case Keyboard.KEY_Z: if (!map_mode) super.keyPressed(event); break; default: if (map_mode || observer) { super.keyPressed(event); } else { if (!getActionButtonPanel().doKeyPressed(event)) super.keyPressed(event); } break; } }
Example 5
Source File: Example13_1.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void keyPressed(int key, char c) { switch(key) { case Keyboard.KEY_P: sphereTimer.togglePause(); break; case Keyboard.KEY_MINUS: sphereTimer.rewind(0.5f); break; case Keyboard.KEY_EQUALS: sphereTimer.fastForward(0.5f); break; case Keyboard.KEY_T: drawCameraPos = !drawCameraPos; break; case Keyboard.KEY_G: drawLights = !drawLights; break; case Keyboard.KEY_1: drawImpostor[0] = !drawImpostor[0]; break; case Keyboard.KEY_2: drawImpostor[1] = !drawImpostor[1]; break; case Keyboard.KEY_3: drawImpostor[2] = !drawImpostor[2]; break; case Keyboard.KEY_4: drawImpostor[3] = !drawImpostor[3]; break; case Keyboard.KEY_L: currentImpostor = Impostors.BASIC; break; case Keyboard.KEY_J: currentImpostor = Impostors.PERSPECTIVE; break; case Keyboard.KEY_H: currentImpostor = Impostors.DEPTH; break; } }
Example 6
Source File: Example12_3.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void keyPressed(int key, char c) { switch(key) { case Keyboard.KEY_P: lights.togglePause(timerMode); break; case Keyboard.KEY_MINUS: lights.rewindTime(timerMode, 1); break; case Keyboard.KEY_EQUALS: lights.fastForwardTime(timerMode, 1); break; case Keyboard.KEY_T: drawCameraPos = !drawCameraPos; break; case Keyboard.KEY_1: timerMode = TimerTypes.TIMER_ALL; System.out.println("All"); break; case Keyboard.KEY_2: timerMode = TimerTypes.TIMER_SUN; System.out.println("Sun"); break; case Keyboard.KEY_3: timerMode = TimerTypes.TIMER_LIGHTS; System.out.println("Lights"); break; case Keyboard.KEY_L: if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) setupGammaLighting(); else setupHDRLighting(); break; case Keyboard.KEY_K: isGammaCorrect = !isGammaCorrect; if(isGammaCorrect) System.out.println("Gamma on!"); else System.out.println("Gamma off!"); break; case Keyboard.KEY_Y: gammaValue += 0.1f; System.out.println("Gamma: " + gammaValue); break; case Keyboard.KEY_H: gammaValue -= 0.1f; if(gammaValue < 1f) gammaValue = 1; System.out.println("Gamma: " + gammaValue); break; case Keyboard.KEY_SPACE: float sunAlpha = lights.getSunTime(); float sunTimeHours = sunAlpha * 24 + 12; sunTimeHours = sunTimeHours > 24 ? sunTimeHours - 24 : sunTimeHours; int sunHours = (int)sunTimeHours; float sunTimeMinutes = (sunTimeHours - sunHours) * 60f; int sunMinutes = (int)sunTimeMinutes; System.out.println(sunHours + ":" + sunMinutes); break; } }
Example 7
Source File: Example12_1.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void keyPressed(int key, char c) { switch(key) { case Keyboard.KEY_P: lights.togglePause(timerMode); break; case Keyboard.KEY_MINUS: lights.rewindTime(timerMode, 1); break; case Keyboard.KEY_EQUALS: lights.fastForwardTime(timerMode, 1); break; case Keyboard.KEY_T: drawCameraPos = !drawCameraPos; break; case Keyboard.KEY_1: timerMode = TimerTypes.TIMER_ALL; System.out.println("All"); break; case Keyboard.KEY_2: timerMode = TimerTypes.TIMER_SUN; System.out.println("Sun"); break; case Keyboard.KEY_3: timerMode = TimerTypes.TIMER_LIGHTS; System.out.println("Lights"); break; case Keyboard.KEY_L: if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) setupNighttimeLighting(); else setupDaytimeLighting(); break; case Keyboard.KEY_SPACE: float sunAlpha = lights.getSunTime(); float sunTimeHours = sunAlpha * 24 + 12; sunTimeHours = sunTimeHours > 24 ? sunTimeHours - 24 : sunTimeHours; int sunHours = (int)sunTimeHours; float sunTimeMinutes = (sunTimeHours - sunHours) * 60f; int sunMinutes = (int)sunTimeMinutes; System.out.println(sunHours + ":" + sunMinutes); break; } }
Example 8
Source File: Example12_2.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void keyPressed(int key, char c) { switch(key) { case Keyboard.KEY_P: lights.togglePause(timerMode); break; case Keyboard.KEY_MINUS: lights.rewindTime(timerMode, 1); break; case Keyboard.KEY_EQUALS: lights.fastForwardTime(timerMode, 1); break; case Keyboard.KEY_T: drawCameraPos = !drawCameraPos; break; case Keyboard.KEY_1: timerMode = TimerTypes.TIMER_ALL; System.out.println("All"); break; case Keyboard.KEY_2: timerMode = TimerTypes.TIMER_SUN; System.out.println("Sun"); break; case Keyboard.KEY_3: timerMode = TimerTypes.TIMER_LIGHTS; System.out.println("Lights"); break; case Keyboard.KEY_L: if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) setupNighttimeLighting(); else setupDaytimeLighting(); break; case Keyboard.KEY_K: setupHDRLighting(); break; case Keyboard.KEY_SPACE: float sunAlpha = lights.getSunTime(); float sunTimeHours = sunAlpha * 24 + 12; sunTimeHours = sunTimeHours > 24 ? sunTimeHours - 24 : sunTimeHours; int sunHours = (int)sunTimeHours; float sunTimeMinutes = (sunTimeHours - sunHours) * 60f; int sunMinutes = (int)sunTimeMinutes; System.out.println(sunHours + ":" + sunMinutes); break; } }