public SingleARMarker(NyARParam i_cparam) throws Exception { JmfCaptureDeviceList devlist = new JmfCaptureDeviceList(); this._ar_param = i_cparam; // キャプチャリソースの準備 this._capture = devlist.getDevice(0); if (!this._capture.setCaptureFormat(SCREEN_X, SCREEN_Y, 30.0f)) { throw new NyARException(); } this._capture.setOnCapture(this); this._cap_image = new JmfNyARRGBRaster(this._capture.getCaptureFormat()); this._code_table[0] = NyARCode.createFromARPattFile(new FileInputStream(CARCODE_FILE1), 16, 16); this._code_table[1] = NyARCode.createFromARPattFile(new FileInputStream(CARCODE_FILE2), 16, 16); // OpenGLフレームの準備(OpenGLリソースの初期化、カメラの撮影開始は、initコールバック関数内で実行) Frame frame = new Frame("NyARToolkit[" + this.getClass().getName() + "]"); GLCanvas canvas = new GLCanvas(); frame.add(canvas); canvas.addGLEventListener(this); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); // ウインドウサイズの調整 frame.setVisible(true); Insets ins = frame.getInsets(); frame.setSize(SCREEN_X + ins.left + ins.right, SCREEN_Y + ins.top + ins.bottom); canvas.setBounds(ins.left, ins.top, SCREEN_X, SCREEN_Y); return; }
public static void main(String[] args) { Frame frame = new Frame("Simple JOGL Application"); GLCanvas canvas = new GLCanvas(); canvas.addGLEventListener(new Project1()); frame.add(canvas); frame.setSize(600, 600); final Animator animator = new Animator(canvas); frame.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { new Thread( new Runnable() { public void run() { animator.stop(); System.exit(0); } }) .start(); } }); frame.setVisible(true); animator.start(); }
public static void main(final String[] argv) { final Frame frame = new Frame("Cg demo (runtime_ogl_vertex_fragment)"); final GLCanvas canvas = new GLCanvas(); canvas.addGLEventListener(new runtime_ogl_vertex_fragment()); frame.add(canvas); frame.setSize(512, 512); final Animator animator = new Animator(canvas); frame.addWindowListener( new WindowAdapter() { @Override public void windowClosing(@SuppressWarnings("unused") final WindowEvent e) { // Run this on another thread than the AWT event queue to // make sure the call to Animator.stop() completes before // exiting new Thread( new Runnable() { public void run() { animator.stop(); System.exit(0); } }) .start(); } }); frame.setVisible(true); animator.start(); // and all the rest happens in the display function... }
public SimpleLiteMStandard(INyARMarkerSystemConfig i_config) throws NyARException { JmfCaptureDeviceList devlist = new JmfCaptureDeviceList(); JmfCaptureDevice d = devlist.getDevice(0); d.setCaptureFormat(i_config.getScreenSize(), 30.0f); this._camera = new NyARJmfCamera(d); // create sensor system this._nyar = new NyARGlMarkerSystem(i_config); // create MarkerSystem this.ids[0] = this._nyar.addARMarker(ARCODE_FILE2, 16, 25, 80); this.ids[1] = this._nyar.addARMarker(ARCODE_FILE, 16, 25, 80); Frame frame = new Frame("NyARTK program"); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); GLCanvas canvas = new GLCanvas(); frame.add(canvas); canvas.addGLEventListener(this); NyARIntSize s = i_config.getNyARParam().getScreenSize(); frame.setVisible(true); Insets ins = frame.getInsets(); frame.setSize(s.w + ins.left + ins.right, s.h + ins.top + ins.bottom); canvas.setBounds(ins.left, ins.top, s.w, s.h); this._camera.start(); }
public Teste() { super("colormatrix"); caps = new GLCapabilities(); canvas = new GLCanvas(caps); canvas.addGLEventListener(this); canvas.addKeyListener(this); add(canvas); }
/** * addNotify, removeNotify, destroy: Avoid reinitialization when the panel is added to another * tab's content pane. Thanks for the idea to Kenneth Russell, * http://www.javagaming.org/forums/index.php?topic=16475.0 */ @Override public void addNotify() { if (!created) { created = true; super.addNotify(); } }
public void choosePresentation(GLCanvas canvas) { PresentationLoader loader = new PresentationLoader(); loader.loadPresentation( presentation, canvas, getLayouter(), getAnimationStyles(), getAnimationPathLayouter()); canvas.requestFocus(); }
@Override public void render(GLCanvas canvas) { gui.getGL().glColor4f(bg_col.getR(), bg_col.getG(), bg_col.getB(), bg_col.getA()); renderQuad(pos.x, pos.y, width, height); GL gl = canvas.getGL(); if (texture != null) { texture.bind(0); gl.glColor4f(fg_col.getR(), fg_col.getG(), fg_col.getB(), fg_col.getA()); gl.glBegin(GL.GL_QUADS); gl.glTexCoord2f(0, 0); gl.glVertex2f(pos.x, pos.y); gl.glTexCoord2f(texture.getImageWidth() / texture.getWidth(), 0); gl.glVertex2f(pos.x + width, pos.y); gl.glTexCoord2f( texture.getImageWidth() / texture.getWidth(), texture.getImageHeight() / texture.getHeight()); gl.glVertex2f(pos.x + width, pos.y - height); gl.glTexCoord2f(0, texture.getImageHeight() / texture.getHeight()); gl.glVertex2f(pos.x, pos.y - height); gl.glEnd(); texture.unbind(); } gui.getGL() .glColor4f(border_col.getR(), border_col.getG(), border_col.getB(), border_col.getA()); renderOutlinedQuad(pos.x, pos.y, width, height); }
public void run() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(640, 480); setLocationRelativeTo(null); setVisible(true); canvas.requestFocusInWindow(); }
public void loadPresentation(File[] files, GLCanvas canvas) { PresentationLoader loader = new PresentationLoader(); loader.loadPresentation( presentation, canvas, getLayouter(), getAnimationStyles(), getAnimationPathLayouter(), files); canvas.requestFocus(); }
@Override protected void finalize() throws Throwable { this.animator.stop(); super.finalize(); }
public void display(GLCanvas canvas) { GL gl = canvas.getGL(); // // render the simulation // try { sim.update(); } catch (Exception e) { Log.println("[Editor] exception in simulation update/calculate paths: " + e.getMessage()); e.printStackTrace(); } renderer.render(sim, canvas); // // render the grid // gl.glColor4f(0.4f, 0.4f, 0.4f, 0.4f); gl.glEnable(GL.GL_BLEND); gl.glBegin(GL.GL_LINES); for (int x = 0; x < 100; x++) { gl.glVertex2f( -50 * Constants.PLANET_MAX_SIZE * 4 + x * Constants.PLANET_MAX_SIZE * 4, -50 * Constants.PLANET_MAX_SIZE * 4); gl.glVertex2f( -50 * Constants.PLANET_MAX_SIZE * 4 + x * Constants.PLANET_MAX_SIZE * 4, 50 * Constants.PLANET_MAX_SIZE * 4); } for (int x = 0; x < 100; x++) { gl.glVertex2f( -50 * Constants.PLANET_MAX_SIZE * 4, -50 * Constants.PLANET_MAX_SIZE * 4 + x * Constants.PLANET_MAX_SIZE * 4); gl.glVertex2f( +50 * Constants.PLANET_MAX_SIZE * 4, -50 * Constants.PLANET_MAX_SIZE * 4 + x * Constants.PLANET_MAX_SIZE * 4); } gl.glDisable(GL.GL_BLEND); gl.glEnd(); // // render rectangle selection // if (drag_start != null && drag_end != null && selected_planets.size() == 0) { gl.glLineWidth(2); gl.glColor4f(1, 1, 1, 1); Widget.renderOutlinedQuad( drag_start.x, drag_start.y, drag_end.x - drag_start.x, -(drag_end.y - drag_start.y)); gl.glLineWidth(1); } // // render reference system // gl.glColor3f(1, 1, 1); gl.glBegin(GL.GL_LINES); gl.glColor3f(1, 0, 0); gl.glVertex2f(Constants.PLANET_MAX_SIZE * 50, 0); gl.glVertex2f(-Constants.PLANET_MAX_SIZE * 50, 0); gl.glColor3f(0, 1, 0); gl.glVertex2f(0, Constants.PLANET_MAX_SIZE * 50); gl.glVertex2f(0, -Constants.PLANET_MAX_SIZE * 50); gl.glEnd(); try { Thread.sleep(5); } catch (InterruptedException e) { } // // check mouse over planet // if (sim.getPlanet( renderer.getCamera().getScreenToWorldX(mouse_pos.x), renderer.getCamera().getScreenToWorldY(mouse_pos.y)) != null && !this.wasGuiIntersected(mouse_pos.x, mouse_pos.y) && drag_start != null) for (WorldAlignementContainer cont : conts) cont.setVisible(false); else for (WorldAlignementContainer cont : conts) cont.setVisible(true); }
@Override public void removeNotify() { if (destroyed) { super.removeNotify(); } }
/** * UserInput constructor. * * <p>To make the new UserInput instance able to receive input, listeners need to be added to a * GLCanvas. * * @param canvas The GLCanvas to which to add the listeners. */ public UserInput(GLCanvas canvas) { canvas.addMouseListener(this); canvas.addMouseMotionListener(this); canvas.addKeyListener(this); }