public JmeBatchRenderBackend(final NiftyJmeDisplay display) { this.display = display; this.batchPool = new ObjectPool<Batch>(new Factory<Batch>() { @Override public Batch createNew() { return new Batch(); } }); }
@Override public void beginBatch(final BlendMode blendMode, final int textureId) { batches.add(batchPool.allocate()); currentBatch = batches.get(batches.size() - 1); currentBatch.begin(blendMode, getTextureAtlas(textureId)); }
@Override public void beginFrame() { log.fine("beginFrame()"); for (int i=0; i<batches.size(); i++) { batchPool.free(batches.get(i)); } batches.clear(); // in case we have pending modifyTexture calls we'll need to execute them now if (!modifyTextureCalls.isEmpty()) { Renderer renderer = display.getRenderer(); for (int i=0; i<modifyTextureCalls.size(); i++) { modifyTextureCalls.get(i).execute(renderer); } modifyTextureCalls.clear(); } }
@Nonnull private CoreBatch createNewBatch() { return batchPool.allocate(); }
public BatchRenderBackendInternal( @Nonnull final GL gl, @Nonnull final BufferFactory bufferFactory, @Nonnull final ImageFactory imageFactory, @Nonnull final MouseCursorFactory mouseCursorFactory) { this.gl = gl; this.bufferFactory = bufferFactory; this.imageFactory = imageFactory; this.mouseCursorFactory = mouseCursorFactory; viewportBuffer = bufferFactory.createNativeOrderedIntBuffer(16); singleTextureIdBuffer = bufferFactory.createNativeOrderedIntBuffer(1); batchPool = new ObjectPool<Batch>(new Factory<Batch>() { @Nonnull @Override public Batch createNew() { return new BatchInternal(gl, bufferFactory); } }); initializeOpenGL(); }
private void deleteBatches() { for (CoreBatch batch : batches) { batchPool.free(batch); } batches.clear(); }
@Nonnull private Batch createNewBatch() { return batchPool.allocate(); }
public BatchRenderBackendCoreProfileInternal( @Nonnull final CoreGL gl, @Nonnull final BufferFactory bufferFactory, @Nonnull final ImageFactory imageFactory, @Nonnull final MouseCursorFactory mouseCursorFactory) { this.gl = gl; this.bufferFactory = bufferFactory; this.imageFactory = imageFactory; this.mouseCursorFactory = mouseCursorFactory; this.saveGLState = new CoreProfileSaveGLState(gl, bufferFactory); viewportBuffer = bufferFactory.createNativeOrderedIntBuffer(16); shader = CoreShader.createShaderWithVertexAttributes(gl, bufferFactory, "aVertex", "aColor", "aTexture"); shader.fragmentShader("nifty.fs"); shader.vertexShader("nifty.vs"); shader.link(); shader.activate(); shader.setUniformi("uTex", 0); batchPool = new ObjectPool<CoreBatch>(new Factory<CoreBatch>() { @Nonnull @Override public CoreBatch createNew() { return new CoreBatchInternal(gl, shader, bufferFactory, PRIMITIVE_RESTART_INDEX); } }); }
private void deleteBatches() { for (Batch batch : batches) { batchPool.free(batch); } batches.clear(); }