Beispiel #1
0
  private void begin(Writer writer, IndWriter indexer, int mode, int blockSize) {
    mDraw.checkErr();

    mActiveWriter = writer;
    mActiveIndexer = indexer;
    mActiveMode = mode;
    mVertBuf.clear();

    int bytes = mVertBuf.capacity();
    int vertBytes = writer.mVertWriter.bytesPerElem();
    mActiveCap = (bytes / (vertBytes * blockSize)) * blockSize;
    mActivePos = 0;

    writer.mProgram.bind(mDraw);
    writer.mVao.bind(mDraw);
    mVbo.bind(mDraw);

    if (indexer != null) {
      indexer.reset();
      mIndBuf.clear();
      mIbo.bind(mDraw);
    }

    DrawUtil.checkErr();
  }
Beispiel #2
0
 public void vert(float x, float y, float z) {
   Vec.put(x, y, z, mVert.mPos);
   mActiveWriter.mVertWriter.write(mVert, mVertBuf);
   if (mActiveIndexer != null) {
     mActiveIndexer.write(mActivePos, mIndBuf);
   }
   if (++mActivePos < mActiveCap) {
     return;
   }
   flush();
 }
Beispiel #3
0
  private void flush() {
    DrawEnv d = mDraw;

    mVertBuf.flip();
    GLES30.glBufferSubData(GL_ARRAY_BUFFER, 0, mVertBuf.remaining(), mVertBuf);
    mVertBuf.clear();

    if (mActiveIndexer == null) {
      GLES30.glDrawArrays(mActiveMode, 0, mActivePos);
    } else {
      mIndBuf.flip();
      GLES30.glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, mIndBuf.remaining(), mIndBuf);
      GLES30.glDrawElements(mActiveMode, mActiveIndexer.count(), GL_UNSIGNED_INT, 0);
      mIndBuf.clear();
    }
    mActivePos = 0;
  }