Esempio n. 1
0
  protected boolean bufferUpdate() {
    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);
      }
      data.rgbBuf.rewind();
      setNative(data.rgbBuf, 0, 0, width, height);

      // Putting the buffer in the used buffers list to dispose at the end of
      // draw.
      if (usedBuffers == null) {
        usedBuffers = new LinkedList<BufferData>();
      }
      usedBuffers.add(data);

      return true;
    } else {
      return false;
    }
  }
Esempio n. 2
0
  /**
   * Creates an instance of PTexture with size width x height and with the specified parameters. The
   * texture is initialized (empty) to that size.
   *
   * @param width int
   * @param height int
   * @param params Parameters
   */
  public Texture(int width, int height, Object params) {
    pgl = PGraphicsOpenGL.pgl;
    context = pgl.createEmptyContext();

    colorBuffer = false;

    glName = 0;

    init(width, height, (Parameters) params);
  }
Esempio n. 3
0
 /**
  * Sets the size of the image and texture to width x height. If the texture is already
  * initialized, it first destroys the current OpenGL texture object and then creates a new one
  * with the specified size.
  *
  * @param width int
  * @param height int
  */
 public void init(int width, int height) {
   Parameters params;
   if (0 < glName) {
     // Re-initializing a pre-existing texture.
     // We use the current parameters as default:
     params = getParameters();
   } else {
     // Just built-in default parameters otherwise:
     params = new Parameters();
   }
   init(width, height, params);
 }
Esempio n. 4
0
  /**
   * Creates an instance of PTexture with size width x height and with the specified parameters. The
   * texture is initialized (empty) to that size.
   *
   * @param parent PApplet
   * @param width int
   * @param height int
   * @param params Parameters
   */
  public Texture(PApplet parent, int width, int height, Object params) {
    this.parent = parent;

    pg = (PGraphicsOpenGL) parent.g;
    pgl = pg.pgl;
    context = pgl.createEmptyContext();

    pgDraw = null;

    glName = 0;

    init(width, height, (Parameters) params);
  }
Esempio n. 5
0
  protected boolean bufferUpdate() {
    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.dispose();

      return true;
    } else {
      return false;
    }
  }