FileDocCategorySizeDatePackage
OpenGLRenderer.javaAPI DocFobs4JMF API 0.4.18143Thu Jan 04 23:57:04 GMT 2007com.omnividea.media.renderer.video

OpenGLRenderer

public class OpenGLRenderer extends Object implements VideoRenderer, FrameGrabbingControl
FOBS Java CrossPlatform JMF PlugIn Copyright (c) 2004 Omnividea Multimedia S.L This file is part of FOBS. FOBS is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. FOBS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with FOBS; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Fields Summary
private BufferStrategy
strategy
private net.java.games.jogl.GLCanvas
canvas
private net.java.games.jogl.Animator
animator
private com.omnividea.media.renderer.video.opengl.RenderEventListener
listener
private com.omnividea.media.renderer.video.opengl.FlatRenderer
flatRenderer
private JPanel
panel
private Image
lastImage
private RGBFormat
vf
private BufferedImage
bufferedImage
private int[]
pixels
private int
formatWidth
private int
formatHeight
private int
currentIndex
Constructors Summary
public OpenGLRenderer()


      
        GLCapabilities capbilities = new GLCapabilities();
        capbilities.setDoubleBuffered(true);
        capbilities.setAlphaBits(8);
        capbilities.setRedBits(8);
        capbilities.setGreenBits(8);
        capbilities.setBlueBits(8);        
        System.out.println("OpenGL Renderer: cons");
        canvas = GLDrawableFactory.getFactory().createGLCanvas(capbilities);
        flatRenderer = new FlatRenderer();
        //flatRenderer.init(canvas);
        addRenderEventListener(flatRenderer);
        panel = new JPanel();
        panel.setIgnoreRepaint(true);
        panel.add(canvas);
    
Methods Summary
public voidaddRenderEventListener(com.omnividea.media.renderer.video.opengl.RenderEventListener listener)

        System.out.println("OpenGL Renderer: add Render Event");
        this.listener = listener;
        canvas.addGLEventListener(listener);
        canvas.addMouseMotionListener(listener);
    
public voidclose()

        
        
    
public java.awt.RectanglegetBounds()

        return null;
    
public java.awt.ComponentgetComponent()

        //return canvas;
        return panel;
    
public java.lang.ObjectgetControl(java.lang.String arg)

 
    Object rc = null; 
    if(arg.equals("javax.media.control.FrameGrabbingControl")) rc = this; 
    return rc; 
  
public java.awt.ComponentgetControlComponent()

 
    return null; 
  
public java.lang.Object[]getControls()

 
    Object[] obj = { this }; 
    return obj; 
  
public java.lang.StringgetName()

        return "Fobs GL Renderer";
    
public javax.media.Format[]getSupportedInputFormats()

        RGBFormat format = new RGBFormat();
        return new Format[] {  format };
    
public javax.media.BuffergrabFrame()

 
    //BufferedImage bufimg = (BufferedImage)FobsConfiguration.properties.get("BufferedImage"); 
    Buffer buf = ImageToBuffer.createBuffer(lastImage,(float)0); 
    return buf; 
  
public voidopen()

    
public intprocess(javax.media.Buffer buffer)

        
        /*int[] bufferdata = (int[]) buffer.getData();
        int nextIndex = (currentIndex +1)%2;
        currentIndex = nextIndex;
        */
        /*
        int[] destination = pixels[nextIndex];
        int size = destination.length;
        int offsetSrc = 0;
        int offsetDest = destination.length - formatWidth;
		for(int i=0; i < formatHeight; ++i) { 
		    for(int j=formatWidth - 1; j >= 0; --j) {
		        destination[offsetDest] = (bufferdata[offsetSrc] << 8);
		        ++offsetDest;
		        ++offsetSrc;
		    }
		    
		    offsetDest -= formatWidth * 2;
		}
		
		if(listener != null) {
		    listener.setRenderingData(pixels[currentIndex]);
            canvas.display();
		}
        */
		if(listener != null) {
		    listener.setRenderingData(pixels/*bufferdata*/);
            canvas.display();
		}

		
		
		return BUFFER_PROCESSED_OK;
    
public voidreset()

    
public voidsetBounds(java.awt.Rectangle arg0)

        System.out.println("set bounds :: " + arg0);
        
    
public booleansetComponent(java.awt.Component arg0)

        return false;
    
public javax.media.FormatsetInputFormat(javax.media.Format format)

        FobsConfiguration.reset();
        FobsConfiguration.videoFrameFormat=FobsConfiguration.YUV420;

/*        vf = (RGBFormat) format;
		this.formatWidth = (int) vf.getSize().getWidth();
	    this.formatHeight = (int) vf.getSize().getHeight();
	    listener.setFormat(formatWidth,formatHeight);
	    pixels[0] = new int[formatWidth * formatHeight];
	    pixels[1] = new int[formatWidth * formatHeight];

        FobsConfiguration.videoFrameFormat=FobsConfiguration.RGBA;*/

        vf = (RGBFormat) format;
		int formatWidth = (int) vf.getSize().getWidth();
	    int formatHeight = (int) vf.getSize().getHeight();
	    listener.setFormat(formatWidth,formatHeight);
        
        /*
        bufferedImage = new BufferedImage(formatWidth,formatHeight, BufferedImage.TYPE_INT_RGB);
        pixels = ( (DataBufferInt) bufferedImage.getRaster().getDataBuffer()).getData();
        
        FobsConfiguration.properties.put("BufferedImage", bufferedImage);
        FobsConfiguration.properties.put("BufferedImageIntBuffer", pixels);
	    */
        
	    canvas.setSize(new Dimension(formatWidth,formatHeight));
	    panel.setPreferredSize(new Dimension(formatWidth,formatHeight));
        return format;
    
voidsetValue(java.lang.Object aValue, boolean isSelected)

    
        
        System.out.println(aValue.getClass().getName());
    
public voidstart()

        /*
        if(animator == null) {
            animator = new Animator(canvas);
            animator.start();
            System.out.println("animator started");
        }*/
        
    
public voidstop()

        /*
        if(animator != null) {
            animator.stop();
            animator = null;
        }
        */