コード例 #1
0
ファイル: Texture.java プロジェクト: svn2github/Processing
  // Copies source texture tex into this.
  protected void copyTexture(
      int texTarget,
      int texName,
      int texWidth,
      int texHeight,
      int x,
      int y,
      int w,
      int h,
      boolean scale) {
    if (tempFbo == null) {
      tempFbo = new FrameBuffer(parent, glWidth, glHeight);
    }

    // This texture is the color (destination) buffer of the FBO.
    tempFbo.setColorBuffer(this);
    tempFbo.disableDepthTest();

    // FBO copy:
    pg.pushFramebuffer();
    pg.setFramebuffer(tempFbo);
    if (scale) {
      // Rendering tex into "this", and scaling the source rectangle
      // to cover the entire destination region.
      pgl.drawTexture(texTarget, texName, texWidth, texHeight, x, y, w, h, 0, 0, width, height);

    } else {
      // Rendering tex into "this" but without scaling so the contents
      // of the source texture fall in the corresponding texels of the
      // destination.
      pgl.drawTexture(texTarget, texName, texWidth, texHeight, x, y, w, h, x, y, w, h);
    }
    pg.popFramebuffer();
    updateTexels(x, y, w, h);
  }
コード例 #2
0
ファイル: Texture.java プロジェクト: svn2github/Processing
  /** Copy texture to pixels. Involves video memory to main memory transfer (slow). */
  public void get(int[] pixels) {
    if (pixels == null) {
      throw new RuntimeException("Trying to copy texture to null pixels array");
    }
    if (pixels.length != width * height) {
      throw new RuntimeException("Trying to copy texture to pixels array of " + "wrong size");
    }

    if (tempFbo == null) {
      tempFbo = new FrameBuffer(parent, glWidth, glHeight);
    }

    // Attaching the texture to the color buffer of a FBO, binding the FBO and
    // reading the pixels from the current draw buffer (which is the color
    // buffer of the FBO).
    tempFbo.setColorBuffer(this);
    pg.pushFramebuffer();
    pg.setFramebuffer(tempFbo);
    tempFbo.readPixels();
    pg.popFramebuffer();

    tempFbo.getPixels(pixels);
    convertToARGB(pixels);

    if (invertedX) flipArrayOnX(pixels, 1);
    if (invertedY) flipArrayOnY(pixels, 1);
  }
コード例 #3
0
 /**
  * Check to see if there are any FrameBuffers that have switched their interest type from read
  * to write or vice versa.
  */
 protected void processInterestChanges() {
   synchronized (selectInterestChanges) {
     for (FrameBuffer fb : selectInterestChanges) {
       fb.changeSelectInterests();
     }
     selectInterestChanges.clear();
   }
 }
コード例 #4
0
 /** Do connection-close cleanup on a given SelectionKey. */
 protected void cleanupSelectionKey(SelectionKey key) {
   // remove the records from the two maps
   FrameBuffer buffer = (FrameBuffer) key.attachment();
   if (buffer != null) {
     // close the buffer
     buffer.close();
   }
   // cancel the selection key
   key.cancel();
 }
コード例 #5
0
  protected void cleanupBuffers() {
    // Delete the capture buffers
    for (int i = 0; i < m_CaptureBuffers.size(); ++i) {
      FrameBuffer buffer = m_CaptureBuffers.get(i);
      buffer.free();
    }

    m_FreeBufferList.clear();
    m_CaptureBuffers.clear();
  }
コード例 #6
0
    /**
     * Do the work required to read from a readable client. If the frame is fully read, then invoke
     * the method call.
     */
    protected void handleRead(SelectionKey key) {
      FrameBuffer buffer = (FrameBuffer) key.attachment();
      if (!buffer.read()) {
        cleanupSelectionKey(key);
        return;
      }

      // if the buffer's frame read is complete, invoke the method.
      if (buffer.isFrameFullyRead()) {
        if (!requestInvoke(buffer)) {
          cleanupSelectionKey(key);
        }
      }
    }
コード例 #7
0
ファイル: RenderGraph.java プロジェクト: danijelz/gurella
 @Override
 void startLayer() {
   frameBuffer = graph.obtainFrameBuffer();
   frameBuffer.bind();
   gl.glClearColor(0, 0, 0, 0);
   gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_STENCIL_BUFFER_BIT);
 }
コード例 #8
0
ファイル: RenderGraph.java プロジェクト: danijelz/gurella
 private FrameBuffer obtainFrameBuffer() {
   if (frameBuffersCache.size > 0) {
     return frameBuffersCache.pop();
   } else {
     return FrameBuffer.obtain(width, height, Format.RGBA8888);
   }
 }
コード例 #9
0
  protected boolean allocateBuffers() {
    // Allocate exactly 3 buffers to use as the capture destination while streaming.
    // These buffers are passed to the SDK.
    for (int i = 0; i < s_NumSdkBuffers; ++i) {
      FrameBuffer buffer =
          m_Stream.allocateFrameBuffer(m_VideoParams.outputWidth * m_VideoParams.outputHeight * 4);
      if (!buffer.getIsValid()) {
        reportError(String.format("Error while allocating frame buffer"));
        return false;
      }

      m_CaptureBuffers.add(buffer);
      m_FreeBufferList.add(buffer);
    }

    return true;
  }
コード例 #10
0
ファイル: TextureManager.java プロジェクト: nileblack/mnc
 public void preWarm(FrameBuffer framebuffer) {
   if (!framebuffer.usesRenderer(1)) return;
   for (int i = 0; i < textureCount; i++) {
     Texture texture = textures[i];
     Texture texture1;
     if (texture != null) texture1 = texture.getMipMappedTexture(1);
   }
 }
コード例 #11
0
ファイル: RenderGraph.java プロジェクト: danijelz/gurella
 @Override
 void endLayer() {
   frameBuffer.unbind();
   Effect effect = layer.effect;
   if (effect != null) {
     effect.process(frameBuffer.texture);
   }
 }
コード例 #12
0
 public void run() {
   if (frameBuffer.trans_ instanceof TNonblockingSocket) {
     TNonblockingSocket tsock = (TNonblockingSocket) frameBuffer.trans_;
     Socket sock = tsock.getSocketChannel().socket();
     clientAddress.set(sock.getInetAddress().getHostAddress() + ":" + sock.getPort());
   }
   frameBuffer.invoke();
 }
コード例 #13
0
ファイル: RenderGraph.java プロジェクト: danijelz/gurella
 @Override
 public void reset() {
   clear();
   externalRootFrameBuffer = 0;
   if (rootFrameBuffer != null) {
     rootFrameBuffer.free();
     rootFrameBuffer = null;
   }
   CanvasUtils.resetArray(frameBuffersCache);
   frameBuffersStack.clear();
   width = 0;
   height = 0;
   glContext = null;
 }
コード例 #14
0
  public OverlappingFrameBuffer(FrameBuffer inner, double overlap) {
    if (overlap <= 0 || overlap >= 1) {
      throw new IllegalArgumentException("overlap should be > 0, < 1.");
    }

    this.overlap = overlap;
    this.inner = inner;
    this.overlapSize = (int) (overlap * inner.getFrameSize());

    numFrames =
        (int)
            Math.floor(
                (inner.getNumFrames() * inner.getFrameSize())
                    / (inner.getFrameSize() - overlapSize));

    double oldFps = inner.getFramesPerSecond();
    double growth = (numFrames / (double) inner.getNumFrames());

    fps = (oldFps * growth);
  }
コード例 #15
0
  public void bufferUnlockCallback(long address) {
    FrameBuffer buffer = FrameBuffer.lookupBuffer(address);

    // Put back on the free list
    m_FreeBufferList.add(buffer);
  }
コード例 #16
0
 @Override
 public double getSampleRate() {
   return inner.getSampleRate();
 }
コード例 #17
0
 @Override
 public int getFrameSize() {
   return inner.getFrameSize();
 }
コード例 #18
0
 /** Let a writable client get written, if there's data to be written. */
 protected void handleWrite(SelectionKey key) {
   FrameBuffer buffer = (FrameBuffer) key.attachment();
   if (!buffer.write()) {
     cleanupSelectionKey(key);
   }
 }
コード例 #19
0
 @Override
 public int getHeight() {
   return frameBuffer.getHeight();
 }
コード例 #20
0
 @Override
 public int getWidth() {
   return frameBuffer.getWidth();
 }
コード例 #21
0
ファイル: RenderBuffer.java プロジェクト: dreamsxin/Emerge
 public boolean isSupported() {
   return FrameBuffer.isSupported();
 }
コード例 #22
0
ファイル: RenderGraph.java プロジェクト: danijelz/gurella
 void init(GlContext glContext, Texture texture) {
   this.glContext = glContext;
   this.width = glContext.getWidth();
   this.height = glContext.getHeight();
   this.rootFrameBuffer = FrameBuffer.obtain(texture);
 }
コード例 #23
0
ファイル: Texture.java プロジェクト: angmark0309/VisioLine
  // Copies source texture tex into this.
  protected void copyTexture(Texture tex, int x, int y, int w, int h, boolean scale) {
    if (tex == null) {
      throw new RuntimeException("Source texture is null");
    }

    if (tempFbo == null) {
      tempFbo = new FrameBuffer(glWidth, glHeight);
    }

    // This texture is the color (destination) buffer of the FBO.
    tempFbo.setColorBuffer(this);
    tempFbo.disableDepthTest();

    // FBO copy:
    PGraphicsOpenGL.pushFramebuffer();
    PGraphicsOpenGL.setFramebuffer(tempFbo);
    // Clear the color buffer to make sure that the alpha channel is set to
    // full transparency
    pgl.clearColor(0, 0, 0, 0);
    pgl.clear(PGL.COLOR_BUFFER_BIT);
    if (scale) {
      // Rendering tex into "this", and scaling the source rectangle
      // to cover the entire destination region.
      pgl.drawTexture(
          tex.glTarget,
          tex.glName,
          tex.glWidth,
          tex.glHeight,
          tempFbo.width,
          tempFbo.height,
          x,
          y,
          w,
          h,
          0,
          0,
          width,
          height);

    } else {
      // Rendering tex into "this" but without scaling so the contents
      // of the source texture fall in the corresponding texels of the
      // destination.
      pgl.drawTexture(
          tex.glTarget,
          tex.glName,
          tex.glWidth,
          tex.glHeight,
          tempFbo.width,
          tempFbo.height,
          x,
          y,
          w,
          h,
          x,
          y,
          w,
          h);
    }
    PGraphicsOpenGL.popFramebuffer();

    updateTexels(x, y, w, h);
  }
コード例 #24
0
 /**
  * Preview frame from the camera
  *
  * @param data Frame
  * @param camera Camera
  */
 public void onPreviewFrame(byte[] data, Camera camera) {
   if (!started) {
     return;
   }
   frameBuffer.setData(data);
 };