Package com.xith3d.render.jogl

Source Code of com.xith3d.render.jogl.PBufferCanvas3D

/*
* Copyright Nicolas Brodu
* License: Blah blah blah. If this becomes part of the Xith3D project,
* it will use the project license. In the meantime, let's say it is LGPL. 
*/
package com.xith3d.render.jogl;

import java.awt.Component;
import java.awt.Frame;
import java.awt.image.BufferedImage;

import com.xith3d.scenegraph.Canvas3D;

/**
* @author Nicolas Brodu
*
* This Canvas3D can be added to a View and will provide
* rendering into an Image made from a pbuffer => uses hardware acceleration
* See notes for PBufferCanvasPeer
*/
public class PBufferCanvas3D extends Canvas3D {

    public static void initContext(Object owner) {
        Frame f = null;
        if (owner==null) {
            f = new Frame();
            f.setBounds(-100,-200,40,30);
            f.show();
            owner = f;
        }
        PBufferCanvasPeer.initContext(owner);
        if (f!=null) f.hide();
        else if (owner instanceof Component) {((Component)owner).repaint();};
    }

    public PBufferCanvas3D(int width, int height) throws RuntimeException {
        this(width, height, null);
    }

  public PBufferCanvas3D(int width, int height, Object owner) throws RuntimeException {
        set3DPeer(new PBufferCanvasPeer(this, new RenderPeerImpl(), owner, width, height, 32, false, null));
    }

    public BufferedImage updateImage() {
        return ((PBufferCanvasPeer)this.get3DPeer()).updateImage();
    }

    public BufferedImage getLastImage() {
        return ((PBufferCanvasPeer)this.get3DPeer()).getLastImage();
    }

    // called by all resize ops
    public void setBounds(int x, int y, int width, int height) {
        super.setBounds(x,y,width,height);
        ((PBufferCanvasPeer)this.get3DPeer()).setSize(width,height);
    }
}
TOP

Related Classes of com.xith3d.render.jogl.PBufferCanvas3D

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.