private void draw(float[] matrix, FloatBuffer vertexBuffer, FloatBuffer uvBuffer, ShortBuffer drawListBuffer, short[] indices) { texture.bindTexture(0); GLES20.glEnable(GLES20.GL_BLEND_COLOR); GLES20.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GLES20.glDepthMask(false); int mPositionHandle = GLES20.glGetAttribLocation(SpriteKitGraphicTools.imageShaderProgram, "vPosition"); GLES20.glEnableVertexAttribArray(mPositionHandle); GLES20.glVertexAttribPointer(mPositionHandle, 3, GLES20.GL_FLOAT, false, 0, vertexBuffer); int mTexCoordLoc = GLES20.glGetAttribLocation(SpriteKitGraphicTools.imageShaderProgram, "a_texCoord"); GLES20.glEnableVertexAttribArray(mTexCoordLoc); GLES20.glVertexAttribPointer(mTexCoordLoc, 2, GLES20.GL_FLOAT, false, 0, uvBuffer); int mtrxhandle = GLES20.glGetUniformLocation(SpriteKitGraphicTools.imageShaderProgram, "uMVPMatrix"); GLES20.glUniformMatrix4fv(mtrxhandle, 1, false, matrix, 0); int mSamplerLoc = GLES20.glGetUniformLocation(SpriteKitGraphicTools.imageShaderProgram, "s_texture"); GLES20.glUniform1i(mSamplerLoc, 0); GLES20.glDrawElements(GLES20.GL_TRIANGLES, indices.length, GLES20.GL_UNSIGNED_SHORT, drawListBuffer); GLES20.glDisableVertexAttribArray(mPositionHandle); GLES20.glDisableVertexAttribArray(mTexCoordLoc); GLES20.glDisable(GLES20.GL_BLEND_COLOR); }
/** * Convert the audio bytes into the stream * * @param format The audio format being decoded * @param audio_bytes The audio byts * @param two_bytes_data True if we using double byte data * @return The byte bufer of data */ private static ByteBuffer convertAudioBytes(AudioFormat format, byte[] audio_bytes, boolean two_bytes_data) { ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length); dest.order(ByteOrder.nativeOrder()); ByteBuffer src = ByteBuffer.wrap(audio_bytes); src.order(ByteOrder.BIG_ENDIAN); if (two_bytes_data) { ShortBuffer dest_short = dest.asShortBuffer(); ShortBuffer src_short = src.asShortBuffer(); while (src_short.hasRemaining()) dest_short.put(src_short.get()); } else { while (src.hasRemaining()) { byte b = src.get(); if (format.getEncoding() == Encoding.PCM_SIGNED) { b = (byte) (b + 127); } dest.put(b); } } dest.rewind(); return dest; }
public Instruction[] readSequenceFrom(ShortBuffer buffer, int startIndex, int length, OffsetToObjectMapping mapping) { ShortBufferBytecodeStream range = new ShortBufferBytecodeStream(buffer, startIndex, length); List<Instruction> insn = new ArrayList<>(length); while (range.hasMore()) { Instruction instruction = readFrom(range, mapping); if (instruction instanceof ConstString) { updateHighestSortingString(((ConstString) instruction).getString()); } else if (instruction instanceof ConstStringJumbo) { updateHighestSortingString(((ConstStringJumbo) instruction).getString()); } insn.add(instruction); } return insn.toArray(new Instruction[insn.size()]); }
private static boolean isDirect(Buffer buf) { if (buf instanceof FloatBuffer) { return ((FloatBuffer) buf).isDirect(); } if (buf instanceof IntBuffer) { return ((IntBuffer) buf).isDirect(); } if (buf instanceof ShortBuffer) { return ((ShortBuffer) buf).isDirect(); } if (buf instanceof ByteBuffer) { return ((ByteBuffer) buf).isDirect(); } if (buf instanceof DoubleBuffer) { return ((DoubleBuffer) buf).isDirect(); } if (buf instanceof LongBuffer) { return ((LongBuffer) buf).isDirect(); } throw new UnsupportedOperationException(" BufferAux.isDirect was called on " + buf.getClass().getName()); }
@Override public void queueInput(ByteBuffer inputBuffer) { if (inputBuffer.hasRemaining()) { ShortBuffer shortBuffer = inputBuffer.asShortBuffer(); int inputSize = inputBuffer.remaining(); inputBytes += inputSize; sonic.queueInput(shortBuffer); inputBuffer.position(inputBuffer.position() + inputSize); } int outputSize = sonic.getSamplesAvailable() * channelCount * 2; if (outputSize > 0) { if (buffer.capacity() < outputSize) { buffer = ByteBuffer.allocateDirect(outputSize).order(ByteOrder.nativeOrder()); shortBuffer = buffer.asShortBuffer(); } else { buffer.clear(); shortBuffer.clear(); } sonic.getOutput(shortBuffer); outputBytes += outputSize; buffer.limit(outputSize); outputBuffer = buffer; } }
/** * Convert the audio bytes into the stream * * @param audio_bytes The audio byts * @param two_bytes_data True if we using double byte data * @return The byte bufer of data */ private static ByteBuffer convertAudioBytes(byte[] audio_bytes, boolean two_bytes_data) { ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length); dest.order(ByteOrder.nativeOrder()); ByteBuffer src = ByteBuffer.wrap(audio_bytes); src.order(ByteOrder.LITTLE_ENDIAN); if (two_bytes_data) { ShortBuffer dest_short = dest.asShortBuffer(); ShortBuffer src_short = src.asShortBuffer(); while (src_short.hasRemaining()) dest_short.put(src_short.get()); } else { while (src.hasRemaining()) dest.put(src.get()); } dest.rewind(); return dest; }
/** * Creates a new ShortBuffer with the same contents as the given ShortBuffer. * The new ShortBuffer is seperate from the old one and changes are not * reflected across. If you want to reflect changes, consider using * Buffer.duplicate(). * * @param buf * the ShortBuffer to copy * @return the copy */ public static ShortBuffer clone(ShortBuffer buf) { if (buf == null) { return null; } buf.rewind(); ShortBuffer copy; if (isDirect(buf)) { copy = createShortBuffer(buf.limit()); } else { copy = ShortBuffer.allocate(buf.limit()); } copy.put(buf); return copy; }
@Test(dataProvider = "shortViewProvider") public void testShortGet(String desc, IntFunction<ByteBuffer> fbb, Function<ByteBuffer, ShortBuffer> fbi) { ByteBuffer bb = allocate(fbb); ShortBuffer vb = fbi.apply(bb); int o = bb.position(); for (int i = 0; i < vb.limit(); i++) { short fromBytes = getShortFromBytes(bb, o + i * 2); short fromMethodView = bb.getShort(o + i * 2); assertValues(i, fromBytes, fromMethodView, bb); short fromBufferView = vb.get(i); assertValues(i, fromMethodView, fromBufferView, bb, vb); } for (int i = 0; i < vb.limit(); i++) { short v = getShortFromBytes(bb, o + i * 2); short a = bb.getShort(); assertValues(i, v, a, bb); short b = vb.get(); assertValues(i, a, b, bb, vb); } }
private ShortBuffer readVorbis(String resource, int bufferSize, STBVorbisInfo info) throws Exception { try (MemoryStack stack = MemoryStack.stackPush()) { vorbis = Utils.ioResourceToByteBuffer(resource, bufferSize); IntBuffer error = stack.mallocInt(1); long decoder = stb_vorbis_open_memory(vorbis, error, null); if (decoder == NULL) { throw new RuntimeException("Failed to open Ogg Vorbis file. Error: " + error.get(0)); } stb_vorbis_get_info(decoder, info); int channels = info.channels(); int lengthSamples = stb_vorbis_stream_length_in_samples(decoder); pcm = MemoryUtil.memAllocShort(lengthSamples); pcm.limit(stb_vorbis_get_samples_short_interleaved(decoder, channels, pcm) * channels); stb_vorbis_close(decoder); return pcm; } }
private byte[] encodeToOpus(byte[] rawAudio) { ShortBuffer nonEncodedBuffer = ShortBuffer.allocate(rawAudio.length / 2); ByteBuffer encoded = ByteBuffer.allocate(4096); for (int i = 0; i < rawAudio.length; i += 2) { int firstByte = (0x000000FF & rawAudio[i]); //Promotes to int and handles the fact that it was unsigned. int secondByte = (0x000000FF & rawAudio[i + 1]); // //Combines the 2 bytes into a short. Opus deals with unsigned shorts, not bytes. short toShort = (short) ((firstByte << 8) | secondByte); nonEncodedBuffer.put(toShort); } nonEncodedBuffer.flip(); //TODO: check for 0 / negative value for error. int result = Opus.INSTANCE.opus_encode(opusEncoder, nonEncodedBuffer, OPUS_FRAME_SIZE, encoded, encoded.capacity()); //ENCODING STOPS HERE byte[] audio = new byte[result]; encoded.get(audio); return audio; }
private long drainOverflow(final ShortBuffer outBuff) { final ShortBuffer overflowBuff = mOverflowBuffer.data; final int overflowLimit = overflowBuff.limit(); final int overflowSize = overflowBuff.remaining(); final long beginPresentationTimeUs = mOverflowBuffer.presentationTimeUs + sampleCountToDurationUs(overflowBuff.position(), mInputSampleRate, mOutputChannelCount); outBuff.clear(); // Limit overflowBuff to outBuff's capacity overflowBuff.limit(outBuff.capacity()); // Load overflowBuff onto outBuff outBuff.put(overflowBuff); if (overflowSize >= outBuff.capacity()) { // Overflow fully consumed - Reset overflowBuff.clear().limit(0); } else { // Only partially consumed - Keep position & restore previous limit overflowBuff.limit(overflowLimit); } return beginPresentationTimeUs; }
private static ByteBuffer convertAudioBytes(byte[] audio_bytes, boolean two_bytes_data, ByteOrder order) { ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length); dest.order(ByteOrder.nativeOrder()); ByteBuffer src = ByteBuffer.wrap(audio_bytes); src.order(order); if (two_bytes_data) { ShortBuffer dest_short = dest.asShortBuffer(); ShortBuffer src_short = src.asShortBuffer(); while (src_short.hasRemaining()) dest_short.put(src_short.get()); } else { while (src.hasRemaining()) dest.put(src.get()); } dest.rewind(); return dest; }
private void allocate(){ ByteBuffer buffer = ResourceLoader.getBytes(path); IntBuffer error = BufferUtils.createIntBuffer(1); long decoder = stb_vorbis_open_memory(buffer, error, null); if(decoder == 0L){ Application.error("Unable to open STB Vorbis"); return; } STBVorbisInfo info = STBVorbisInfo.malloc(); stb_vorbis_get_info(decoder, info); int channels = info.channels(); int lengthSamples = stb_vorbis_stream_length_in_samples(decoder); ShortBuffer pcm = BufferUtils.createShortBuffer(lengthSamples); pcm.limit(stb_vorbis_get_samples_short_interleaved(decoder, channels, pcm) * channels); stb_vorbis_close(decoder); AL10.alBufferData(id, info.channels() == 1? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, pcm, info.sample_rate()); }
public void run() { android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO); this.isInitialized = false; if (audioRecord != null) { //判断音频录制是否被初始化 while (this.audioRecord.getState() == 0) { try { Thread.sleep(100L); } catch (InterruptedException localInterruptedException) { } } this.isInitialized = true; this.audioRecord.startRecording(); while (((runAudioThread) || (mVideoTimestamp > mAudioTimestamp)) && (mAudioTimestamp < (1000 * RECORDING_TIME))) { updateTimestamp(); bufferReadResult = this.audioRecord.read(audioData, 0, audioData.length); if ((bufferReadResult > 0) && ((recording && rec) || (mVideoTimestamp > mAudioTimestamp))) record(ShortBuffer.wrap(audioData, 0, bufferReadResult)); } this.audioRecord.stop(); this.audioRecord.release(); } }
public static ShortBuffer ensureLargeEnough(ShortBuffer buffer, int required) { if (buffer != null) { buffer.limit(buffer.capacity()); } if (buffer == null || (buffer.remaining() < required)) { int position = (buffer != null ? buffer.position() : 0); ShortBuffer newVerts = createShortBuffer(position + required); if (buffer != null) { buffer.flip(); newVerts.put(buffer); newVerts.position(position); } buffer = newVerts; } return buffer; }
public static ShortBuffer getIndices(int size) { if (size > indexSize) { indexSize = size; indices = ByteBuffer. allocateDirect(size * SIZE * Short.SIZE / 8). order(ByteOrder.nativeOrder()). asShortBuffer(); short[] values = new short[size * 6]; int pos = 0; int limit = size * 4; for (int ofs = 0; ofs < limit; ofs += 4) { values[pos++] = (short) (ofs + 0); values[pos++] = (short) (ofs + 1); values[pos++] = (short) (ofs + 2); values[pos++] = (short) (ofs + 0); values[pos++] = (short) (ofs + 2); values[pos++] = (short) (ofs + 3); } indices.put(values); indices.position(0); } return indices; }
void asViewPutOne(Buffer v, PrimitiveType t, int index) { switch (t) { case BYTE: ((ByteBuffer) v).put(index, (byte)0); break; case CHAR: ((CharBuffer) v).put(index, '0'); break; case SHORT: ((ShortBuffer) v).put(index, (short)0); break; case INT: ((IntBuffer) v).put(index, 0); break; case LONG: ((LongBuffer) v).put(index, 0); break; case FLOAT: ((FloatBuffer) v).put(index, 0); break; case DOUBLE: ((DoubleBuffer) v).put(index, 0); break; } }
/** * shortBuffer包含了音频的数据和起始位置 * * @param shortBuffer */ private void record(ShortBuffer shortBuffer) { try { if (videoRecorder != null) { this.mCount += shortBuffer.limit(); videoRecorder.record(0, new Buffer[]{shortBuffer}); } } catch (FrameRecorder.Exception localException) { } return; }
private void setUnderlineMetrics(ByteBuffer postTable, int upem) { if (postTable == null || postTable.capacity() < 12 || upem < 0) { ulSize = .05f; ulPos = .1f; return; } ShortBuffer sb = postTable.asShortBuffer(); ulSize = sb.get(5) / (float)upem; ulPos = -sb.get(4) / (float)upem; }
public static void glDrawElementsInstancedBaseVertexBaseInstance(int mode, ShortBuffer indices, int primcount, int basevertex, int baseinstance) { if (Properties.VALIDATE.enabled) { checkBeforeDrawCall(); } if (Properties.PROFILE.enabled) { RT.beforeDraw(); } org.lwjgl.opengl.GL42.glDrawElementsInstancedBaseVertexBaseInstance(mode, indices, primcount, basevertex, baseinstance); if (Properties.PROFILE.enabled) { RT.draw(indices.remaining() * primcount); } }
/** * Queues remaining data from {@code buffer}, and advances its position by the number of bytes * consumed. * * @param buffer A {@link ShortBuffer} containing input data between its position and limit. */ public void queueInput(ShortBuffer buffer) { int samplesToWrite = buffer.remaining() / numChannels; int bytesToWrite = samplesToWrite * numChannels * 2; enlargeInputBufferIfNeeded(samplesToWrite); buffer.get(inputBuffer, numInputSamples * numChannels, bytesToWrite / 2); numInputSamples += samplesToWrite; processStreamInput(); }
public void drawElements( FloatBuffer vertices, ShortBuffer indices, int size ) { vertices.position( 0 ); aXY.vertexPointer( 2, 4, vertices ); vertices.position( 2 ); aUV.vertexPointer( 2, 4, vertices ); Quad.releaseIndices(); GLES20.glDrawElements( GLES20.GL_TRIANGLES, size, GLES20.GL_UNSIGNED_SHORT, indices ); Quad.bindIndices(); }
public static ShortBuffer createShortBufferFromArray(short[] data) { if (data == null) { return null; } ShortBuffer buff = createShortBuffer(data.length); buff.clear(); buff.put(data); buff.flip(); return buff; }
public static void glDrawElementsInstancedEXT(int mode, ShortBuffer indices, int primcount) { if (Properties.VALIDATE.enabled) { checkBeforeDrawCall(); } if (Properties.PROFILE.enabled) { RT.beforeDraw(); } org.lwjgl.opengl.EXTDrawInstanced.glDrawElementsInstancedEXT(mode, indices, primcount); if (Properties.PROFILE.enabled) { RT.draw(indices.remaining() * primcount); } }
public void write(ShortBuffer dest, ObjectToOffsetMapping mapping) { writeFirst(1, dest); // Pseudo-opcode = 0x0100 write16BitValue(size, dest); write32BitValue(first_key, dest); for (int i = 0; i < size; i++) { write32BitValue(targets[i], dest); } }
public static void createBuffers() { final FloatBuffer heightMapVertexDataBuffer = ByteBuffer .allocateDirect(aHeightMapVertexData.length * BYTES_PER_FLOAT).order(ByteOrder.nativeOrder()) .asFloatBuffer(); heightMapVertexDataBuffer.put(aHeightMapVertexData).position(0); final ShortBuffer heightMapIndexDataBuffer = ByteBuffer .allocateDirect(aHeightMapIndexData.length * BYTES_PER_SHORT).order(ByteOrder.nativeOrder()) .asShortBuffer(); heightMapIndexDataBuffer.put(aHeightMapIndexData).position(0); if (vbo[0] > 0 && ibo[0] > 0) { GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vbo[0]); GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, heightMapVertexDataBuffer.capacity() * BYTES_PER_FLOAT, heightMapVertexDataBuffer, GLES20.GL_STATIC_DRAW); GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, ibo[0]); GLES20.glBufferData(GLES20.GL_ELEMENT_ARRAY_BUFFER, heightMapIndexDataBuffer.capacity() * BYTES_PER_SHORT, heightMapIndexDataBuffer, GLES20.GL_STATIC_DRAW); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0); } else { GlUtil.checkGlError("glGenBuffers"); } }
public static ShortBuffer getIndices( int size ) { ShortBuffer indices = cache.get(size); if (indices == null) { // TODO: Optimize it! indices = ByteBuffer. allocateDirect( size * SIZE * Short.SIZE / 8 ). order( ByteOrder.nativeOrder() ). asShortBuffer(); short[] values = new short[size * 6]; int pos = 0; int limit = size * 4; for (int ofs=0; ofs < limit; ofs += 4) { values[pos++] = (short)(ofs + 0); values[pos++] = (short)(ofs + 1); values[pos++] = (short)(ofs + 2); values[pos++] = (short)(ofs + 0); values[pos++] = (short)(ofs + 2); values[pos++] = (short)(ofs + 3); } indices.put( values ); indices.position( 0 ); cache.put(size, indices); } return indices; }
void asViewGetOne(Buffer v, PrimitiveType t, int index) { switch (t) { case BYTE: ((ByteBuffer) v).get(index); break; case CHAR: ((CharBuffer) v).get(index); break; case SHORT: ((ShortBuffer) v).get(index); break; case INT: ((IntBuffer) v).get(index); break; case LONG: ((LongBuffer) v).get(index); break; case FLOAT: ((FloatBuffer) v).get(index); break; case DOUBLE: ((DoubleBuffer) v).get(index); break; } }
private static GuardedInvocation linkSetElement(final Object self) { MethodHandle method = null; MethodHandle guard = null; if (self instanceof ByteBuffer) { method = BYTEBUFFER_PUT; guard = IS_BYTEBUFFER; } else if (self instanceof CharBuffer) { method = CHARBUFFER_PUT; guard = IS_CHARBUFFER; } else if (self instanceof ShortBuffer) { method = SHORTBUFFER_PUT; guard = IS_SHORTBUFFER; } else if (self instanceof IntBuffer) { method = INTBUFFER_PUT; guard = IS_INTBUFFER; } else if (self instanceof LongBuffer) { method = LONGBUFFER_PUT; guard = IS_LONGBUFFER; } else if (self instanceof FloatBuffer) { method = FLOATBUFFER_PUT; guard = IS_FLOATBUFFER; } else if (self instanceof DoubleBuffer) { method = DOUBLEBUFFER_PUT; guard = IS_DOUBLEBUFFER; } return method != null? new GuardedInvocation(method, guard) : null; }
protected void allocateBufferSignal() { if (mConfig.pcmFormat == FSKConfig.PCM_8BIT) { mSignalPCM8 = ByteBuffer.allocate(mConfig.sampleRate); //1 second buffer } else if (mConfig.pcmFormat == FSKConfig.PCM_16BIT) { mSignalPCM16 = ShortBuffer.allocate(mConfig.sampleRate); //1 second buffer } }
public static void glDrawElementsBaseVertex(int mode, ShortBuffer indices, int basevertex) { if (Properties.VALIDATE.enabled) { checkBeforeDrawCall(); } if (Properties.PROFILE.enabled) { RT.beforeDraw(); } org.lwjgl.opengl.ARBDrawElementsBaseVertex.glDrawElementsBaseVertex(mode, indices, basevertex); if (Properties.PROFILE.enabled) { RT.draw(indices.remaining()); } }
private void setStrikethroughMetrics(ByteBuffer os_2Table, int upem) { if (os_2Table == null || os_2Table.capacity() < 30 || upem < 0) { stSize = .05f; stPos = -.4f; return; } ShortBuffer sb = os_2Table.asShortBuffer(); stSize = sb.get(13) / (float)upem; stPos = -sb.get(14) / (float)upem; }
@Override public void remix(final ShortBuffer inSBuff, final ShortBuffer outSBuff) { // Down-mix stereo to mono // Viktor Toth's algorithm - // See: http://www.vttoth.com/CMS/index.php/technical-notes/68 // http://stackoverflow.com/a/25102339 final int inRemaining = inSBuff.remaining() / 2; final int outSpace = outSBuff.remaining(); final int samplesToBeProcessed = Math.min(inRemaining, outSpace); for (int i = 0; i < samplesToBeProcessed; ++i) { // Convert to unsigned final int a = inSBuff.get() + SIGNED_SHORT_LIMIT; final int b = inSBuff.get() + SIGNED_SHORT_LIMIT; int m; // Pick the equation if ((a < SIGNED_SHORT_LIMIT) || (b < SIGNED_SHORT_LIMIT)) { // Viktor's first equation when both sources are "quiet" // (i.e. less than middle of the dynamic range) m = a * b / SIGNED_SHORT_LIMIT; } else { // Viktor's second equation when one or both sources are loud m = 2 * (a + b) - (a * b) / SIGNED_SHORT_LIMIT - UNSIGNED_SHORT_MAX; } // Convert output back to signed short if (m == UNSIGNED_SHORT_MAX + 1) m = UNSIGNED_SHORT_MAX; outSBuff.put((short) (m - SIGNED_SHORT_LIMIT)); } }
public static void glDrawElementsBaseVertex(int mode, ShortBuffer indices, int basevertex) { if (Properties.VALIDATE.enabled) { checkBeforeDrawCall(); } if (Properties.PROFILE.enabled) { RT.beforeDraw(); } org.lwjgl.opengl.GL32.glDrawElementsBaseVertex(mode, indices, basevertex); if (Properties.PROFILE.enabled) { RT.draw(indices.remaining()); } }
/** * creates buffers for Quad shape object * @param pos * @param widths */ public void createBuffers( float[] pos, float[] widths) { createVertexData(pos, widths); final FloatBuffer heightMapVertexDataBuffer = ByteBuffer .allocateDirect(aQuadVertexData.length * BYTES_PER_FLOAT).order(ByteOrder.nativeOrder()) .asFloatBuffer(); heightMapVertexDataBuffer.put(aQuadVertexData).position(0); final ShortBuffer heightMapIndexDataBuffer = ByteBuffer .allocateDirect(aQuadIndexData.length * BYTES_PER_SHORT).order(ByteOrder.nativeOrder()) .asShortBuffer(); heightMapIndexDataBuffer.put(aQuadIndexData).position(0); if (qvbo[0] > 0 && qibo[0] > 0) { GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, qvbo[0]); GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, heightMapVertexDataBuffer.capacity() * BYTES_PER_FLOAT, heightMapVertexDataBuffer, GLES20.GL_STATIC_DRAW); GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, qibo[0]); GLES20.glBufferData(GLES20.GL_ELEMENT_ARRAY_BUFFER, heightMapIndexDataBuffer.capacity() * BYTES_PER_SHORT, heightMapIndexDataBuffer, GLES20.GL_STATIC_DRAW); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0); } else { GlUtil.checkGlError("glGenBuffers"); } }
@AndroidIncompatible // problem with equality of Type objects? public void testFreshInstance() { assertFreshInstances( String.class, CharSequence.class, Appendable.class, StringBuffer.class, StringBuilder.class, Pattern.class, MatchResult.class, Number.class, int.class, Integer.class, long.class, Long.class, short.class, Short.class, byte.class, Byte.class, boolean.class, Boolean.class, char.class, Character.class, int[].class, Object[].class, UnsignedInteger.class, UnsignedLong.class, BigInteger.class, BigDecimal.class, Throwable.class, Error.class, Exception.class, RuntimeException.class, Charset.class, Locale.class, Currency.class, List.class, Map.Entry.class, Object.class, Equivalence.class, Predicate.class, Function.class, Comparable.class, Comparator.class, Ordering.class, Class.class, Type.class, TypeToken.class, TimeUnit.class, Ticker.class, Joiner.class, Splitter.class, CharMatcher.class, InputStream.class, ByteArrayInputStream.class, Reader.class, Readable.class, StringReader.class, OutputStream.class, ByteArrayOutputStream.class, Writer.class, StringWriter.class, File.class, Buffer.class, ByteBuffer.class, CharBuffer.class, ShortBuffer.class, IntBuffer.class, LongBuffer.class, FloatBuffer.class, DoubleBuffer.class, String[].class, Object[].class, int[].class); }
public static void setupIndices() { ShortBuffer indices = getIndices(Short.MAX_VALUE); if (bufferIndex == -1) { int[] buf = new int[1]; GLES20.glGenBuffers(1, buf, 0); bufferIndex = buf[0]; } GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, bufferIndex); GLES20.glBufferData(GLES20.GL_ELEMENT_ARRAY_BUFFER, (indices.capacity() * 2), indices, GLES20.GL_STATIC_DRAW); GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0); }