public void onSurfaceCreated() { // log.debug(GL.getString(GL20.EXTENSIONS)); String vendor = gl.getString(GL.VENDOR); String renderer = gl.getString(GL.RENDERER); String version = gl.getString(GL.VERSION); log.debug("{}/{}/{}", vendor, renderer, version); // Prevent issue with Adreno 3xx series if (renderer != null && renderer.startsWith("Adreno (TM) 3")) { log.debug("==> not using glBufferSubData"); GLAdapter.NO_BUFFER_SUB_DATA = true; } GLState.init(); // Set up some vertex buffer objects BufferObject.init(200); // classes that require GL context for initialization RenderBuckets.initRenderer(); mNewSurface = true; }
public void onSurfaceChanged(int width, int height) { // log.debug("onSurfaceChanged: new={}, {}x{}", mNewSurface, width, height); if (width <= 0 || height <= 0) return; gl.viewport(0, 0, width, height); // GL.scissor(0, 0, width, height); // GL.enable(GL20.SCISSOR_TEST); gl.clearStencil(0x00); gl.disable(GL.CULL_FACE); gl.blendFunc(GL.ONE, GL.ONE_MINUS_SRC_ALPHA); gl.frontFace(GL.CW); gl.cullFace(GL.BACK); if (!mNewSurface) { mMap.updateMap(false); return; } mNewSurface = false; /** initialize quad indices used by Texture- and LineTexRenderer */ int[] vboIds = GLUtils.glGenBuffers(2); mQuadIndicesID = vboIds[0]; short[] indices = new short[MAX_INDICES]; for (int i = 0, j = 0; i < MAX_INDICES; i += 6, j += 4) { indices[i + 0] = (short) (j + 0); indices[i + 1] = (short) (j + 1); indices[i + 2] = (short) (j + 2); indices[i + 3] = (short) (j + 2); indices[i + 4] = (short) (j + 1); indices[i + 5] = (short) (j + 3); } ShortBuffer buf = MapRenderer.getShortBuffer(indices.length); buf.put(indices); buf.flip(); GLState.bindElementBuffer(mQuadIndicesID); gl.bufferData(GL.ELEMENT_ARRAY_BUFFER, indices.length * 2, buf, GL.STATIC_DRAW); GLState.bindElementBuffer(0); /** initialize default quad */ FloatBuffer floatBuffer = MapRenderer.getFloatBuffer(8); float[] quad = new float[] {-1, -1, -1, 1, 1, -1, 1, 1}; floatBuffer.put(quad); floatBuffer.flip(); mQuadVerticesID = vboIds[1]; GLState.bindVertexBuffer(mQuadVerticesID); gl.bufferData(GL.ARRAY_BUFFER, quad.length * 4, floatBuffer, GL.STATIC_DRAW); GLState.bindVertexBuffer(0); GLState.init(); mMap.updateMap(true); }