本文整理汇总了Java中javax.media.opengl.awt.GLCanvas.addGLEventListener方法的典型用法代码示例。如果您正苦于以下问题:Java GLCanvas.addGLEventListener方法的具体用法?Java GLCanvas.addGLEventListener怎么用?Java GLCanvas.addGLEventListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.opengl.awt.GLCanvas
的用法示例。
在下文中一共展示了GLCanvas.addGLEventListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Picking
import javax.media.opengl.awt.GLCanvas; //导入方法依赖的package包/类
Picking()
{
Frame frame = new Frame("Picking Example");
GLCapabilities capabilities = new GLCapabilities(null);
GLCanvas drawable = new GLCanvas(capabilities);
final Renderer renderer = new Renderer();
drawable.addGLEventListener(renderer);
drawable.addMouseListener(renderer);
drawable.addMouseMotionListener(renderer);
frame.add(drawable);
frame.setSize(400, 400);
final Animator animator = new Animator(drawable);
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
animator.stop();
System.exit(0);
}
});
frame.setVisible(true);
animator.start();
}
示例2: getOpenGLProblems
import javax.media.opengl.awt.GLCanvas; //导入方法依赖的package包/类
public static String getOpenGLProblems()
{
GLCapabilities caps = new GLCapabilities(GLProfile.getMaxFixedFunc(true));
caps.setAlphaBits(8);
caps.setRedBits(8);
caps.setGreenBits(8);
caps.setBlueBits(8);
caps.setDepthBits(24);
caps.setDoubleBuffered(true);
GLCanvas canvas = new GLCanvas(caps);
OpenGLTestCapabilities testClass = new OpenGLTestCapabilities();
canvas.addGLEventListener(testClass);
return testClass.messages.toString();
}
示例3: testOpenGL
import javax.media.opengl.awt.GLCanvas; //导入方法依赖的package包/类
private static boolean testOpenGL()
{
GLCapabilities caps = new GLCapabilities(GLProfile.getMaxFixedFunc(true));
caps.setAlphaBits(8);
caps.setRedBits(8);
caps.setGreenBits(8);
caps.setBlueBits(8);
caps.setDepthBits(24);
caps.setDoubleBuffered(true);
GLCanvas canvas = new GLCanvas(caps);
OpenGLTestCapabilities testClass = new OpenGLTestCapabilities();
canvas.addGLEventListener(testClass);
testedPreviously = true;
previouslyTestedAsOpenGLCapable = !testClass.fail;
return !testClass.fail;
}
示例4: initUI
import javax.media.opengl.awt.GLCanvas; //导入方法依赖的package包/类
private void initUI() {
this.width = 600;
this.height = 400;
GLCapabilities config = new GLCapabilities(GLProfile.get(GLProfile.GL2));
config.setSampleBuffers(true);
config.setNumSamples(4);
GLCanvas canvas = new GLCanvas(config);
canvas.addGLEventListener(this);
usi.init(canvas);
JFrame frame = new JFrame("JOGL-JOCL Interoperability Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(canvas);
frame.setSize(width, height);
frame.setVisible(true);
}
示例5: main
import javax.media.opengl.awt.GLCanvas; //导入方法依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
GLProfile.initSingleton();
GLProfile glp = GLProfile.getDefault();
GLCapabilities caps = new GLCapabilities(glp);
GLCanvas canvas = new GLCanvas(caps);
Frame frame = new Frame("Test Surface rendering in JOGL 2 using nurbs or eval-mesh");
frame.setSize(300, 300);
frame.add(canvas);
frame.setVisible(true);
// by default, an AWT Frame doesn't do anything when you click
// the close button; this bit of code will terminate the program when
// the window is asked to close
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
canvas.addGLEventListener(new SurfaceTest());
FPSAnimator animator = new FPSAnimator(canvas, 5);
//animator.add(canvas);
animator.start();
}
示例6: createUI_90_OpenGL
import javax.media.opengl.awt.GLCanvas; //导入方法依赖的package包/类
private void createUI_90_OpenGL(final Composite parent) {
_glCanvas = new GLCanvas(_glCaps);
_glCanvas.addGLEventListener(new GLInfo());
_glCanvas.setSize(10, 10);
// set parent griddata, this must be done AFTER the content is created, otherwise it fails !!!
// GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);
// build GUI: container(SWT) -> Frame(AWT) -> Panel(AWT) -> WorldWindowGLCanvas(AWT)
_mapContainer = _tk.createComposite(parent, SWT.EMBEDDED);
GridDataFactory.fillDefaults().hint(10, 20).applyTo(_mapContainer);
{
_awtFrame = SWT_AWT.new_Frame(_mapContainer);
final java.awt.Panel awtPanel = new java.awt.Panel(new java.awt.BorderLayout());
_awtFrame.add(awtPanel);
awtPanel.add(_glCanvas, BorderLayout.CENTER);
}
_mapContainer.setVisible(false);
parent.layout();
}
示例7: Scene
import javax.media.opengl.awt.GLCanvas; //导入方法依赖的package包/类
Scene(Kengine kengine){
this.kengine = kengine;
GLProfile glprofile = GLProfile.getDefault();
GLCapabilities glcapabilities = new GLCapabilities( glprofile );
canvas = new GLCanvas(glcapabilities);
canvas.setSize(kengine.getWidth(), kengine.getHeight());
canvas.addGLEventListener(this);
canvas.addMouseMotionListener(mkMouseAdapter());
canvas.addMouseListener(mkMouseAdapter());
canvas.addKeyListener(mkKeyAdapter());
canvas.requestFocus();
fpsa = new FPSAnimator(canvas,60,true);
fpsa.start();
kengine.add(canvas);
hideCursor();
try {
rob = new Robot();
} catch (AWTException e) {
e.printStackTrace();
}
mouseCenter = (int) (kengine.getHeight()*.5);
}
示例8: setup
import javax.media.opengl.awt.GLCanvas; //导入方法依赖的package包/类
/**
* Create the GLCanvas and set properties for the graphics device
* initialization, such as bits per channel. And advanced features for
* improved rendering performance such as the stencil buffer.
*/
private void setup() {
GLProfile glp = GLProfile.getDefault();
// Specifies a set of OpenGL capabilities, based on your profile.
GLCapabilities caps = new GLCapabilities(glp);
caps.setDoubleBuffered(true);
caps.setHardwareAccelerated(true);
// create the canvas for drawing
canvas = new GLCanvas(caps);
// create the render thread
anim = new Animator();
// add the canvas to the main window
add(canvas, BorderLayout.CENTER);
// need this to receive callbacks for rendering (i.e. display() method)
canvas.addGLEventListener(this);
}
示例9: Renderer
import javax.media.opengl.awt.GLCanvas; //导入方法依赖的package包/类
public Renderer(Callback c, KeyListener k) {
callback = c;
GLProfile glp = GLProfile.getDefault();
GLCapabilities caps = new GLCapabilities(glp);
canvas = new GLCanvas(caps);
setTitle("Rainbot");
setSize(camera.getDim()[0], camera.getDim()[1]);
canvas.setIgnoreRepaint(true);
canvas.addGLEventListener(this);
if(k==null)
k=this;
canvas.addKeyListener(k);
canvas.setVisible(true);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
add(canvas, java.awt.BorderLayout.CENTER);
setVisible(true);
}
示例10: MainWindow
import javax.media.opengl.awt.GLCanvas; //导入方法依赖的package包/类
public MainWindow(CSpaceViewer viewer) {
GLProfile glp = GLProfile.get(GLProfile.GL2);
GLCapabilities glc = new GLCapabilities(glp);
glc.setSampleBuffers(true);
glc.setNumSamples(8);
glc.setDepthBits(32);
canvas = new GLCanvas(glc);
animator = new FPSAnimator(canvas, 60);
toolBar = new MainToolBar(viewer);
setTitle("Configuration Space Visualization");
setLayout(new BorderLayout());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(1280, 720);
setLocationRelativeTo(null);
getContentPane().add(toolBar, BorderLayout.SOUTH);
getContentPane().add(canvas, BorderLayout.CENTER);
canvas.addGLEventListener(emptyScene);
animator.start();
}
示例11: initGL
import javax.media.opengl.awt.GLCanvas; //导入方法依赖的package包/类
private static void initGL() {
GLCanvas canvas = new GLCanvas();
canvas.setPreferredSize(new Dimension(Constant.CANVAS_WIDTH,
Constant.CANVAS_HEIGHT));
JFrame frame = new JFrame();
frame.getContentPane().add(canvas);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.setTitle(Constant.TITLE);
frame.pack();
frame.setVisible(true);
canvas.addGLEventListener(new ShaderTest());
FPSAnimator animator = new FPSAnimator(canvas, 60);
animator.start();
}
示例12: setCanvasProvider
import javax.media.opengl.awt.GLCanvas; //导入方法依赖的package包/类
protected void setCanvasProvider(CanvasProvider canvasProvider) {
final GLCanvas oldCanvas = getCanvas();
final GLEventListener glEventListener = getGlEventListener();
if(oldCanvas != null)
oldCanvas.removeGLEventListener(glEventListener);
this.canvasProvider = canvasProvider;
if(canvasProvider != null){
final GLCanvas canvas = canvasProvider.getCanvas();
final GL gl = canvas.getGL();
final Class<? extends GL> desiredClass = getGLClass();
if(! desiredClass.isAssignableFrom(gl.getClass())){
throw new IllegalArgumentException(
"CanvasProvider gives a "+gl.getClass().getName()+
" but expected a GL instance of type "+desiredClass.getName());}
canvas.addGLEventListener(glEventListener);
}
}
示例13: play
import javax.media.opengl.awt.GLCanvas; //导入方法依赖的package包/类
public void play() {
GLProfile glp = GLProfile.getDefault();
GLCapabilities caps = new GLCapabilities(glp);
GLCanvas canvas = new GLCanvas(caps);
frame = new Frame("0");
frame.setSize(300, 300);
frame.add(canvas);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
Pong.close();
}
});
canvas.addGLEventListener(new EventListener(this));
canvas.addKeyListener(new KeyboardListener(this));
FPSAnimator animator = new FPSAnimator(canvas, 200);
animator.add(canvas);
animator.start();
}
示例14: TestFrameComponent
import javax.media.opengl.awt.GLCanvas; //导入方法依赖的package包/类
public TestFrameComponent() {
super("test");
/*
* display mode (single buffer and RGBA)
*/
GLProfile prof=GLProfile.getDefault();
caps = new GLCapabilities(prof);
caps.setDoubleBuffered(false);
System.out.println(caps.toString());
canvas = new GLCanvas(caps);
canvas.addGLEventListener(this);
//
getContentPane().add(canvas);
}
示例15: processNewResult
import javax.media.opengl.awt.GLCanvas; //导入方法依赖的package包/类
@Override
public void processNewResult(ResultHierarchy baseResult, Result newResult) {
Database db = ResultUtil.findDatabase(baseResult);
if(db == null) {
return;
}
// Build OpenGL data loader:
ScatterData data = null;
for(Relation<?> rel : db.getRelations()) {
if(data == null) {
data = new ScatterData(rel.getDBIDs());
}
data.addRelation(rel);
}
if(data == null) {
return;
}
final JFrame jframe = new JFrame("OpenGL Scatterplot");
jframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
final ScatterPlot3DVisualization plot = new ScatterPlot3DVisualization(data);
GLCanvas glcanvas = new GLCanvas(new GLCapabilities(GLProfile.getDefault()));
glcanvas.addGLEventListener(plot);
jframe.getContentPane().add(glcanvas, BorderLayout.CENTER);
jframe.setSize(640, 480);
jframe.setVisible(true);
plot.start(glcanvas);
}