本文整理汇总了Java中com.jogamp.newt.opengl.GLWindow.addKeyListener方法的典型用法代码示例。如果您正苦于以下问题:Java GLWindow.addKeyListener方法的具体用法?Java GLWindow.addKeyListener怎么用?Java GLWindow.addKeyListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.newt.opengl.GLWindow
的用法示例。
在下文中一共展示了GLWindow.addKeyListener方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attachInputListenerTo
import com.jogamp.newt.opengl.GLWindow; //导入方法依赖的package包/类
@Override
public void attachInputListenerTo(final GLWindow window) {
if ( null == keyAction ) {
keyAction = new KeyAction();
window.addKeyListener(keyAction);
super.attachInputListenerTo(window);
}
}
示例2: main
import com.jogamp.newt.opengl.GLWindow; //导入方法依赖的package包/类
public static void main(final String[] args) {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities(glp);
caps.setAlphaBits(4);
caps.setSampleBuffers(true);
caps.setNumSamples(4);
System.out.println("Requested: " + caps);
final GLWindow window = GLWindow.create(caps);
window.setPosition(10, 10);
window.setSize(800, 400);
window.setTitle("GPU UI Newt Demo 01");
final RenderState rs = RenderState.createRenderState(SVertex.factory());
final UIGLListener01 uiGLListener = new UIGLListener01 (0, rs, DEBUG, TRACE);
uiGLListener.attachInputListenerTo(window);
window.addGLEventListener(uiGLListener);
window.setVisible(true);
final Animator animator = new Animator();
animator.setUpdateFPSFrames(60, System.err);
animator.add(window);
window.addKeyListener(new KeyAdapter() {
public void keyPressed(final KeyEvent arg0) {
if(arg0.getKeyCode() == KeyEvent.VK_F4) {
window.destroy();
}
}
});
window.addWindowListener(new WindowAdapter() {
public void windowDestroyed(final WindowEvent e) {
animator.stop();
}
});
animator.start();
}
示例3: attachInputListenerTo
import com.jogamp.newt.opengl.GLWindow; //导入方法依赖的package包/类
/** Attach the input listener to the window */
public void attachInputListenerTo(final GLWindow window) {
if ( null == keyAction ) {
keyAction = new KeyAction();
window.addKeyListener(keyAction);
}
if ( null == mouseAction ) {
mouseAction = new MouseAction();
window.addMouseListener(mouseAction);
}
}
示例4: attachInputListenerTo
import com.jogamp.newt.opengl.GLWindow; //导入方法依赖的package包/类
/** Attach the input listener to the window */
public void attachInputListenerTo(final GLWindow window) {
if ( null == keyAction ) {
keyAction = new KeyAction();
window.addKeyListener(keyAction);
}
}
示例5: main
import com.jogamp.newt.opengl.GLWindow; //导入方法依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
Logger.getLogger("").setLevel(Level.WARNING);
// create GL canvas
GLProfile glp = Engine.getProfile();
GLCapabilities caps = new GLCapabilities(glp);
// create GL window
GLWindow glWindow = GLWindow.create(caps);
glWindow.setTitle("EngineTest");
// animator
FPSAnimator animator = new FPSAnimator(glWindow, 60);
// tdme level editor
EngineTest engineTest = new EngineTest(glWindow, animator);
// GL Window
glWindow.addGLEventListener(engineTest);
glWindow.setSize(800, 600);
glWindow.setVisible(true);
glWindow.addKeyListener(engineTest);
glWindow.addMouseListener(engineTest);
glWindow.addWindowListener(engineTest);
// start animator
animator.setUpdateFPSFrames(3, null);
animator.start();
}
示例6: main
import com.jogamp.newt.opengl.GLWindow; //导入方法依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
Logger.getLogger("").setLevel(Level.WARNING);
// create GL canvas
GLProfile glp = Engine.getProfile();
GLCapabilities caps = new GLCapabilities(glp);
// create GL window
GLWindow glWindow = GLWindow.create(caps);
glWindow.setTitle("PhysicsTest1");
// animator
FPSAnimator animator = new FPSAnimator(glWindow, 60);
// tdme level editor
PhysicsTest1 physicsTest1 = new PhysicsTest1();
// GL Window
glWindow.addGLEventListener(physicsTest1);
glWindow.setSize(800, 600);
glWindow.setVisible(true);
glWindow.addKeyListener(physicsTest1);
glWindow.addMouseListener(physicsTest1);
glWindow.addWindowListener(physicsTest1);
// start animator
animator.setUpdateFPSFrames(3, null);
animator.start();
}
示例7: main
import com.jogamp.newt.opengl.GLWindow; //导入方法依赖的package包/类
/**
* Main
* @param args
*/
public static void main(String[] args) {
Logger.getLogger("").setLevel(Level.WARNING);
// create GL canvas
GLProfile glp = Engine.getProfile();
GLCapabilities caps = new GLCapabilities(glp);
// create GL window
GLWindow glWindow = GLWindow.create(caps);
glWindow.setTitle("PhysicsTest2");
// animator
FPSAnimator animator = new FPSAnimator(glWindow, 60);
// tdme level editor
PhysicsTest2 physicsTest2 = new PhysicsTest2();
// GL Window
glWindow.addGLEventListener(physicsTest2);
glWindow.setSize(800, 600);
glWindow.setVisible(true);
glWindow.addKeyListener(physicsTest2);
glWindow.addMouseListener(physicsTest2);
glWindow.addWindowListener(physicsTest2);
// start animator
animator.setUpdateFPSFrames(3, null);
animator.start();
}
示例8: main
import com.jogamp.newt.opengl.GLWindow; //导入方法依赖的package包/类
/**
* Main
* @param args
*/
public static void main(String[] args) {
Logger.getLogger("").setLevel(Level.WARNING);
// create GL canvas
GLProfile glp = Engine.getProfile();
GLCapabilities caps = new GLCapabilities(glp);
// create GL window
GLWindow glWindow = GLWindow.create(caps);
glWindow.setTitle("PhysicsTest3");
// animator
FPSAnimator animator = new FPSAnimator(glWindow, 60);
// tdme level editor
PhysicsTest3 physicsTest3 = new PhysicsTest3();
// GL Window
glWindow.addGLEventListener(physicsTest3);
glWindow.setSize(800, 600);
glWindow.setVisible(true);
glWindow.addKeyListener(physicsTest3);
glWindow.addMouseListener(physicsTest3);
glWindow.addWindowListener(physicsTest3);
// start animator
animator.setUpdateFPSFrames(3, null);
animator.start();
}
示例9: NeonNewtWindow
import com.jogamp.newt.opengl.GLWindow; //导入方法依赖的package包/类
/**
* Constructor for this class. Sets up the window and enables common
* features like anti-aliasing and hardware acceleration.
*
* @param forceGL2ES2
* Force GL2ES2 support (default on), currently Unused
* @param inputHandler
* A predefined InputHandler that is added as event handler for
* input events.
* @param glEventListener
* A predefined GLEventListener that is added as event handler
* for openGL events.
* @param width
* The initial window width.
* @param height
* The initial window height.
* @param windowTitle
* The window title.
*/
public NeonNewtWindow(boolean forceGL2ES2, InputHandler inputHandler, final GLEventListener glEventListener,
int width, int height, String windowTitle) {
GLProfile.initSingleton();
final GLProfile glp;
glp = GLProfile.get(GLProfile.GL3);
// Set up the GL context
final GLCapabilities caps = new GLCapabilities(glp);
caps.setBackgroundOpaque(true);
caps.setHardwareAccelerated(true);
caps.setDoubleBuffered(true);
// Add Anti-Aliasing
caps.setSampleBuffers(true);
caps.setAlphaBits(4);
caps.setNumSamples(4);
GLWindow window = GLWindow.create(caps);
window.addGLEventListener(glEventListener);
window.addWindowListener(new QuitListener());
window.setAutoSwapBufferMode(true);
window.setSize(width, height);
window.setTitle(windowTitle);
window.addMouseListener(inputHandler);
window.addKeyListener(inputHandler);
Animator animator = new Animator();
animator.add(window);
animator.start();
animator.setUpdateFPSFrames(60, null);
window.setVisible(true);
}
示例10: InputHandler
import com.jogamp.newt.opengl.GLWindow; //导入方法依赖的package包/类
/**
* Initializes the inputs and sets up a {@code Robot} that controls the mouse.
* @param c
*/
public InputHandler(Controller c) {
this.c = c;
GLWindow win = c.getWindow();
try {
robot = new Robot();
} catch (AWTException e) {
throw new RuntimeException("The program will not function properly with the current permissions");
}
win.addKeyListener(this);
win.addMouseListener(this);
focused = false;
mouseSensitivity = 1.0/45/200;
//Initialize keys
keyCode = new int[NUM_KEYS];
keyCode[0] = KeyEvent.VK_W;
keyCode[1] = KeyEvent.VK_S;
keyCode[2] = KeyEvent.VK_A;
keyCode[3] = KeyEvent.VK_D;
keyCode[4] = KeyEvent.VK_SHIFT;
keyCode[5] = KeyEvent.VK_Q;
keyCode[6] = KeyEvent.VK_E;
keyCode[7] = KeyEvent.VK_1;
keyCode[8] = KeyEvent.VK_2;
keyCode[9] = KeyEvent.VK_3;
keyCode[10] = KeyEvent.VK_4;
keyCode[11] = KeyEvent.VK_V;
keyCode[12] = KeyEvent.VK_SPACE;
keyCode[13] = KeyEvent.VK_R;
keyCode[14] = KeyEvent.VK_DELETE;
keyCode[15] = KeyEvent.VK_EQUALS;
keyCode[16] = KeyEvent.VK_MINUS;
keyCode[17] = KeyEvent.VK_P;
keyCode[18] = KeyEvent.VK_O;
keyCode[19] = KeyEvent.VK_5;
keyCode[20] = KeyEvent.VK_6;
keyCode[21] = KeyEvent.VK_CONTROL;
keyCode[22] = KeyEvent.VK_F1;
keyCode[23] = KeyEvent.VK_F2;
mouseButton = new int[NUM_MOUSE_BUTTONS];
mouseButton[0] = MouseEvent.BUTTON1;
mouseButton[1] = MouseEvent.BUTTON3;
//Initialize key and mouse control variables.
keyDown = new boolean[NUM_KEYS];
keyCanceled = new boolean[NUM_KEYS];
keyPressed = new boolean[NUM_KEYS];
keyHelper = new boolean[NUM_KEYS];
mouseDown = new boolean[NUM_MOUSE_BUTTONS];
mouseCanceled = new boolean[NUM_MOUSE_BUTTONS];
mousePressed = new boolean[NUM_MOUSE_BUTTONS];
mouseHelper = new boolean[NUM_MOUSE_BUTTONS];
for (int i=0; i<NUM_KEYS; i++) {
keyDown[i] = false;
keyCanceled[i] = false;
keyPressed[i] = false;
keyHelper[i] = false;
}
for (int i=0; i<NUM_MOUSE_BUTTONS; i++) {
mouseDown[i] = false;
mouseCanceled[i] = false;
mousePressed[i] = false;
mouseHelper[i] = false;
}
}