コード例 #1
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);
  }
コード例 #2
0
ファイル: Texture.java プロジェクト: angmark0309/VisioLine
 public void getBufferPixels(int[] pixels) {
   BufferData data = null;
   if (usedBuffers != null && 0 < usedBuffers.size()) {
     // the last used buffer is the one currently stored in the opengl the
     // texture
     data = usedBuffers.getLast();
   } else if (bufferCache != null && 0 < bufferCache.size()) {
     // The first buffer in the cache will be uploaded to the opengl texture
     // the next time it is rendered
     data = bufferCache.getFirst();
   }
   if (data != null) {
     data.rgbBuf.rewind();
     data.rgbBuf.get(pixels);
     convertToARGB(pixels);
   }
 }
コード例 #3
0
ファイル: Texture.java プロジェクト: svn2github/Processing
  protected boolean bufferUpdate(int[] pixels) {
    BufferData data = null;
    try {
      data = bufferCache.remove(0);
    } catch (NoSuchElementException ex) {
      PGraphics.showWarning("Don't have pixel data to copy to texture");
    }

    if (data != null) {
      if ((data.w != width) || (data.h != height)) {
        init(data.w, data.h);
      }
      setNative(data.rgbBuf, 0, 0, width, height);

      data.rgbBuf.get(pixels);
      convertToARGB(pixels);

      data.dispose();

      return true;
    } else {
      return false;
    }
  }