本文整理匯總了Java中java.nio.FloatBuffer.position方法的典型用法代碼示例。如果您正苦於以下問題:Java FloatBuffer.position方法的具體用法?Java FloatBuffer.position怎麽用?Java FloatBuffer.position使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.nio.FloatBuffer
的用法示例。
在下文中一共展示了FloatBuffer.position方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isSupported
import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
* @return Whether the device supports anisotropic filtering.
*/
public static boolean isSupported () {
GL20 gl = Gdx.gl;
if (gl != null) {
if (Gdx.graphics.supportsExtension("GL_EXT_texture_filter_anisotropic")) {
anisotropySupported = true;
FloatBuffer buffer = BufferUtils.newFloatBuffer(16);
buffer.position(0);
buffer.limit(buffer.capacity());
Gdx.gl20.glGetFloatv(GL20.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, buffer);
maxAnisotropySupported = buffer.get(0);
}
checkComplete = true;
}
return anisotropySupported;
}
示例2: makeFloatBuffer
import java.nio.FloatBuffer; //導入方法依賴的package包/類
static FloatBuffer makeFloatBuffer(int size) {
ByteBuffer vbb = ByteBuffer.allocateDirect(size * 4);
vbb.order(ByteOrder.nativeOrder());
FloatBuffer texBuffer = vbb.asFloatBuffer();
texBuffer.position(0);
return texBuffer;
}
示例3: getBuffers
import java.nio.FloatBuffer; //導入方法依賴的package包/類
FloatBuffer[] getBuffers(
float[] cubePositions,
float[] cubeNormals,
float[] cubeTextureCoordinates, int generatedCubeFactor) {
// First, copy cube information into client-side floating point buffers.
final FloatBuffer cubePositionsBuffer;
final FloatBuffer cubeNormalsBuffer;
final FloatBuffer cubeTextureCoordinatesBuffer;
cubePositionsBuffer = ByteBuffer.allocateDirect(cubePositions.length * BYTES_PER_FLOAT)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
cubePositionsBuffer.put(cubePositions).position(0);
cubeNormalsBuffer = ByteBuffer.allocateDirect(cubeNormals.length * BYTES_PER_FLOAT * generatedCubeFactor * generatedCubeFactor * generatedCubeFactor)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
for (int i = 0; i < (generatedCubeFactor * generatedCubeFactor * generatedCubeFactor); i++) {
cubeNormalsBuffer.put(cubeNormals);
}
cubeNormalsBuffer.position(0);
cubeTextureCoordinatesBuffer = ByteBuffer.allocateDirect(cubeTextureCoordinates.length * BYTES_PER_FLOAT * generatedCubeFactor * generatedCubeFactor * generatedCubeFactor)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
for (int i = 0; i < (generatedCubeFactor * generatedCubeFactor * generatedCubeFactor); i++) {
cubeTextureCoordinatesBuffer.put(cubeTextureCoordinates);
}
cubeTextureCoordinatesBuffer.position(0);
return new FloatBuffer[]{cubePositionsBuffer, cubeNormalsBuffer, cubeTextureCoordinatesBuffer};
}
示例4: getFloatBufferFromList
import java.nio.FloatBuffer; //導入方法依賴的package包/類
private FloatBuffer getFloatBufferFromList(List<Float> vertexList) {
ByteBuffer vbb = ByteBuffer.allocateDirect(vertexList.size() * 4);
vbb.order(ByteOrder.nativeOrder());
FloatBuffer triangleBuffer = vbb.asFloatBuffer();
float[] array = new float[vertexList.size()];
for (int i = 0; i < vertexList.size(); i++) {
array[i] = vertexList.get(i);
}
triangleBuffer.put(array);
triangleBuffer.position(0);
return triangleBuffer;
}
示例5: getFloatBufferFromArray
import java.nio.FloatBuffer; //導入方法依賴的package包/類
private FloatBuffer getFloatBufferFromArray(float[] vertexArray) {
ByteBuffer vbb = ByteBuffer.allocateDirect(vertexArray.length * 4);
vbb.order(ByteOrder.nativeOrder());
FloatBuffer triangleBuffer = vbb.asFloatBuffer();
triangleBuffer.put(vertexArray);
triangleBuffer.position(0);
return triangleBuffer;
}
示例6: createTexCoordBuffer
import java.nio.FloatBuffer; //導入方法依賴的package包/類
public static FloatBuffer createTexCoordBuffer() {
final float vtx[] = {
// UV
0f, 1f,
0f, 0f,
1f, 1f,
1f, 0f,
};
ByteBuffer bb = ByteBuffer.allocateDirect(4 * vtx.length);
bb.order(ByteOrder.nativeOrder());
FloatBuffer fb = bb.asFloatBuffer();
fb.put(vtx);
fb.position(0);
return fb;
}
示例7: glMultMatrixf
import java.nio.FloatBuffer; //導入方法依賴的package包/類
public void glMultMatrixf(FloatBuffer m) {
int position = m.position();
mCurrent.glMultMatrixf(m);
m.position(position);
mgl.glMultMatrixf(m);
if ( _check) check();
}
示例8: createFloatBuffer
import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
* Allocates a direct float buffer, and populates it with the float array data.
*/
public static FloatBuffer createFloatBuffer(float[] coords) {
// Allocate a direct ByteBuffer, using 4 bytes per float, and copy coords into it.
ByteBuffer bb = ByteBuffer.allocateDirect(coords.length * SIZEOF_FLOAT);
bb.order(ByteOrder.nativeOrder());
FloatBuffer fb = bb.asFloatBuffer();
fb.put(coords);
fb.position(0);
return fb;
}
示例9: createFloatBuffer
import java.nio.FloatBuffer; //導入方法依賴的package包/類
public static FloatBuffer createFloatBuffer(float[] coords) {
// Allocate a direct ByteBuffer, using 4 bytes per float, and copy coords into it.
ByteBuffer bb = ByteBuffer.allocateDirect(coords.length * 4);
bb.order(ByteOrder.nativeOrder());
FloatBuffer fb = bb.asFloatBuffer();
fb.put(coords);
fb.position(0);
return fb;
}
示例10: draw
import java.nio.FloatBuffer; //導入方法依賴的package包/類
public void draw(final int textureId, final FloatBuffer cubeBuffer,
final FloatBuffer textureBuffer) {
GLES20.glUseProgram(mGLProgId);
runPendingOnDrawTasks();
if (!mIsInitialized) {
return;
}
cubeBuffer.position(0);
GLES20.glVertexAttribPointer(mGLAttribPosition, 3, GLES20.GL_FLOAT, false, 0, cubeBuffer);
GLES20.glEnableVertexAttribArray(mGLAttribPosition);
textureBuffer.position(0);
GLES20.glVertexAttribPointer(mGLAttribTextureCoordinate, 2, GLES20.GL_FLOAT, false, 0,
textureBuffer);
GLES20.glEnableVertexAttribArray(mGLAttribTextureCoordinate);
if (textureId != OpenGlUtils.NO_TEXTURE) {
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(mTextureTarget, textureId);
GLES20.glUniform1i(mGLUniformTexture, 0);
}
onDrawArraysPre();
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 6);
GLES20.glDisableVertexAttribArray(mGLAttribPosition);
GLES20.glDisableVertexAttribArray(mGLAttribTextureCoordinate);
GLES20.glBindTexture(mTextureTarget, 0);
Log.i(TAG,"java filter draw textureId = " + textureId);
if(mInputSurface != null){
mInputSurface.swapBuffers();
GLES20.glFlush();
}
}
示例11: snapshotToBuffer
import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
* Convert the timeseries snapshot into a run of (x, y, z) bytes.
*/
private FloatBuffer snapshotToBuffer(TimeSeriesSnapshot snapshot) {
float[] asFloats = snapshotToFloat(snapshot);
// Create buffer to store result.
ByteBuffer bb = ByteBuffer.allocateDirect(snapshot.length * VERTEX_STRIDE);
bb.order(ByteOrder.nativeOrder());
// Write to buffer usign floats:
FloatBuffer vertexBuffer = bb.asFloatBuffer();
vertexBuffer.put(asFloats);
vertexBuffer.position(0);
return vertexBuffer;
}
示例12: renderTexture
import java.nio.FloatBuffer; //導入方法依賴的package包/類
public int renderTexture(int textureId){
if(mGpuImageFilter == null){
mGpuImageFilter = new GPUImageFilter(null);
mGpuImageFilter.init();
}
int vertexNum = 6;
float[] vertexCoordinate = {1.0f, -1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f,
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f};
ByteBuffer bbVertices = ByteBuffer.allocateDirect(vertexNum * 3 * 4);
bbVertices.order(ByteOrder.nativeOrder());
FloatBuffer vertexBuf = bbVertices.asFloatBuffer();
vertexBuf.put(vertexCoordinate);
vertexBuf.position(0);
float[] textureCoordinate1 = {1.0f, 1.0f,
1.0f, 0.0f,
0.0f, 0.0f,
0.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f};
ByteBuffer bbColors1 = ByteBuffer.allocateDirect(vertexNum * 2 * 4);
bbColors1.order(ByteOrder.nativeOrder());
FloatBuffer textureCoordinateBuf = bbColors1.asFloatBuffer();
textureCoordinateBuf.put(textureCoordinate1);
textureCoordinateBuf.position(0);
mGpuImageFilter.draw(textureId,vertexBuf,textureCoordinateBuf);
return 1;
}
示例13: createVbo
import java.nio.FloatBuffer; //導入方法依賴的package包/類
public static int createVbo(FloatBuffer data) {
int[] vbos = new int[1];
data.position(0);
GLES20.glGenBuffers(1, vbos, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vbos[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, data.capacity() * MyGLUtils.FLOAT_SIZE, data,
GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
return vbos[0];
}
示例14: uploadVerticesBuffer
import java.nio.FloatBuffer; //導入方法依賴的package包/類
public void uploadVerticesBuffer(int positionHandle){
FloatBuffer vertexBuffer = getVerticesBuffer();
if (vertexBuffer == null) return;
vertexBuffer.position(0);
GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 0, vertexBuffer);
ShaderUtils.checkGlError("glVertexAttribPointer maPosition");
GLES20.glEnableVertexAttribArray(positionHandle);
ShaderUtils.checkGlError("glEnableVertexAttribArray maPositionHandle");
}
示例15: draw
import java.nio.FloatBuffer; //導入方法依賴的package包/類
@Override
public void draw(int textureId, FloatBuffer cubeBuffer, FloatBuffer textureBuffer) {
GLES20.glUseProgram(mProgram);
if (mMaskGrey1TextureId == -1) {
ondraw();//
}
cubeBuffer.position(0);
GLES20.glVertexAttribPointer(mAPositionHandle, 2, GLES20.GL_FLOAT, false, 0, cubeBuffer);
GLES20.glEnableVertexAttribArray(mAPositionHandle);
textureBuffer.position(0);
GLES20.glVertexAttribPointer(mATextureCoordinateHandle, 2, GLES20.GL_FLOAT, false, 0, textureBuffer);
GLES20.glEnableVertexAttribArray(mATextureCoordinateHandle);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
GLES20.glUniform1i(mUTextureHandle, 0);
GLES20.glUniformMatrix4fv(mUMVPMatrixHandle, 1, false, mMVPMatrix, 0);
onDrawArraysPre();//
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
onDrawArraysAfter();//
GLES20.glDisableVertexAttribArray(mAPositionHandle);
GLES20.glDisableVertexAttribArray(mATextureCoordinateHandle);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
}