本文整理汇总了Java中java.nio.FloatBuffer.limit方法的典型用法代码示例。如果您正苦于以下问题:Java FloatBuffer.limit方法的具体用法?Java FloatBuffer.limit怎么用?Java FloatBuffer.limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.FloatBuffer
的用法示例。
在下文中一共展示了FloatBuffer.limit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CubesWithVboWithStride
import java.nio.FloatBuffer; //导入方法依赖的package包/类
CubesWithVboWithStride(float[] cubePositions, float[] cubeNormals, float[] cubeTextureCoordinates, int generatedCubeFactor) {
FloatBuffer cubeBuffer = getInterleavedBuffer(cubePositions, cubeNormals, cubeTextureCoordinates, generatedCubeFactor);
// Second, copy these buffers into OpenGL's memory. After, we don't need to keep the client-side buffers around.
final int buffers[] = new int[1];
GLES20.glGenBuffers(1, buffers, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, cubeBuffer.capacity() * BYTES_PER_FLOAT, cubeBuffer, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
mCubeBufferIdx = buffers[0];
cubeBuffer.limit(0);
cubeBuffer = null;
}
示例2: CubesWithVboWithStride
import java.nio.FloatBuffer; //导入方法依赖的package包/类
CubesWithVboWithStride(float[] cubePositions, float[] cubeNormals, float[] cubeTextureCoordinates, int generatedCubeFactor) {
FloatBuffer cubeBuffer = getInterleavedBuffer(cubePositions, cubeNormals, cubeTextureCoordinates, generatedCubeFactor);
// Second, copy these buffers into OpenGL's memory. After, we don't need to keep the client-side buffers around.
final int buffers[] = new int[1];
GLES20.glGenBuffers(1, buffers, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, cubeBuffer.capacity() * BYTES_PER_FLOAT, cubeBuffer, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
mCubeBufferIdx = buffers[0];
cubeBuffer.limit(0);
cubeBuffer = null;
}
示例3: calcShape
import java.nio.FloatBuffer; //导入方法依赖的package包/类
public static IFrustrumShape calcShape(FloatBuffer vert, int dimensions){
if(vert.limit()==0) return new FrustrumBool(false);
Vec3f start=new Vec3f(),end=new Vec3f();
for(int i=0;i<vert.limit();i+=dimensions){
float p1=vert.get(i+0);
start.x(Math.min(start.x(), p1));
end.x(Math.max(end.x(), p1));
if(dimensions>1){
float p2=vert.get(i+1);
start.y(Math.min(start.y(), p2));
end.y(Math.max(end.y(), p2));
if(dimensions>2){
float p3=vert.get(i+2);
start.z(Math.min(start.z(), p3));
end.z(Math.max(end.z(), p3));
}
}
}
return new FrustrumCube(start, end);
}
示例4: 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;
}
示例5: updateData
import java.nio.FloatBuffer; //导入方法依赖的package包/类
public VBO updateData(FloatBuffer buffer, long offset)
{
if (this.type != GL11.GL_FLOAT)
{
throw new IllegalArgumentException("Cannot store mismatching type in buffer!");
}
if (offset + buffer.limit() > this.length)
{
int usage = GL15.glGetBufferParameteri(this.target, GL15.GL_BUFFER_USAGE);
this.putData(buffer, this.normalized, usage);
}
GL15.glBindBuffer(this.target, this.handle);
GL15.glBufferSubData(this.target, offset, buffer);
return this;
}
示例6: predictImage
import java.nio.FloatBuffer; //导入方法依赖的package包/类
/**
* Does actual classification by finding the most probable number to be on the image.
*
* @param image
* byte array of the image to be classified
* @return most probable number to be in the image
*/
private String predictImage(float[] image) {
Tensor img = new Tensor(DT_FLOAT, new TensorShape(1, image.length));
FloatBuffer imgBuff = img.createBuffer();
imgBuff.limit(image.length);
imgBuff.put(image);
TensorVector outputs = new TensorVector();
Status status = session.Run(new StringTensorPairVector(new String[] { "images" }, new Tensor[] { img }),
new StringVector("softmax_linear/logits"), new StringVector("softmax_linear/logits"), outputs);
checkStatus(status);
FloatBuffer output = outputs.get(0).createBuffer();
int maxPos = 0;
float maxY = Float.MIN_VALUE;
for (int i = 0; i < output.limit(); i++) {
float yi = output.get(i);
if (yi > maxY) {
maxY = yi;
maxPos = i;
}
}
return Integer.toString(maxPos);
}
示例7: ensureLargeEnough
import java.nio.FloatBuffer; //导入方法依赖的package包/类
/**
* Ensures there is at least the <code>required</code> number of entries left after the current position of the
* buffer. If the buffer is too small a larger one is created and the old one copied to the new buffer.
* @param buffer buffer that should be checked/copied (may be null)
* @param required minimum number of elements that should be remaining in the returned buffer
* @return a buffer large enough to receive at least the <code>required</code> number of entries, same position as
* the input buffer, not null
*/
public static FloatBuffer ensureLargeEnough(FloatBuffer buffer, int required) {
if (buffer != null) {
buffer.limit(buffer.capacity());
}
if (buffer == null || (buffer.remaining() < required)) {
int position = (buffer != null ? buffer.position() : 0);
FloatBuffer newVerts = createFloatBuffer(position + required);
if (buffer != null) {
buffer.flip();
newVerts.put(buffer);
newVerts.position(position);
}
buffer = newVerts;
}
return buffer;
}
示例8: add0
import java.nio.FloatBuffer; //导入方法依赖的package包/类
private FloatBuffer add0(ModelAttribute type, int toAdd){
if(type.size!=toAdd) throw new IllegalAccessError("Bad attibute size!"+type.size+"/"+toAdd);
int id=vtIds.get(type.id);
FloatBuffer b=data[id];
if(b.limit()<=b.position()+toAdd) b=data[id]=BufferUtil.expand(b, (int)((b.position()+toAdd)*1.5));
dirty=true;
return b;
}
示例9: toVertexArray
import java.nio.FloatBuffer; //导入方法依赖的package包/类
public static Vertex[] toVertexArray(FloatBuffer data)
{
Vertex[] vertices = new Vertex[data.limit() / Vertex.FLOATS];
for(int i=0; i<vertices.length; i++)
{
vertices[i] = new Vertex();
vertices[i].setPos(new Vec3f(data.get(),data.get(),data.get()));
vertices[i].setTextureCoord(new Vec2f(data.get(),data.get()));
vertices[i].setNormal(new Vec3f(data.get(),data.get(),data.get()));
}
return vertices;
}
示例10: Vertexbuffer
import java.nio.FloatBuffer; //导入方法依赖的package包/类
public Vertexbuffer(FloatBuffer vertices) {
synchronized (buffers) {
int[] ptr = new int[1];
GLES20.glGenBuffers(1, ptr, 0);
id = ptr[0];
this.vertices = vertices;
buffers.add(this);
updateStart = 0;
updateEnd = vertices.limit();
}
}
示例11: Vertexbuffer
import java.nio.FloatBuffer; //导入方法依赖的package包/类
public Vertexbuffer( FloatBuffer vertices ) {
synchronized (buffers) {
int[] ptr = new int[1];
GLES20.glGenBuffers(1, ptr, 0);
id = ptr[0];
this.vertices = vertices;
buffers.add(this);
updateStart = 0;
updateEnd = vertices.limit();
}
}
示例12: putData
import java.nio.FloatBuffer; //导入方法依赖的package包/类
public VBO putData(FloatBuffer buffer, boolean normalized, int usage)
{
GL15.glBindBuffer(this.target, this.handle);
GL15.glBufferData(this.target, buffer, usage);
this.type = GL11.GL_FLOAT;
this.normalized = normalized;
this.length = buffer.limit();
return this;
}
示例13: CubesWithVbo
import java.nio.FloatBuffer; //导入方法依赖的package包/类
CubesWithVbo(float[] cubePositions, float[] cubeNormals, float[] cubeTextureCoordinates, int generatedCubeFactor) {
FloatBuffer[] floatBuffers = getBuffers(cubePositions, cubeNormals, cubeTextureCoordinates, generatedCubeFactor);
FloatBuffer cubePositionsBuffer = floatBuffers[0];
FloatBuffer cubeNormalsBuffer = floatBuffers[1];
FloatBuffer cubeTextureCoordinatesBuffer = floatBuffers[2];
// Second, copy these buffers into OpenGL's memory. After, we don't need to keep the client-side buffers around.
final int buffers[] = new int[3];
GLES20.glGenBuffers(3, buffers, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, cubePositionsBuffer.capacity() * BYTES_PER_FLOAT, cubePositionsBuffer, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[1]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, cubeNormalsBuffer.capacity() * BYTES_PER_FLOAT, cubeNormalsBuffer, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[2]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, cubeTextureCoordinatesBuffer.capacity() * BYTES_PER_FLOAT, cubeTextureCoordinatesBuffer,
GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
mCubePositionsBufferIdx = buffers[0];
mCubeNormalsBufferIdx = buffers[1];
mCubeTexCoordsBufferIdx = buffers[2];
cubePositionsBuffer.limit(0);
cubePositionsBuffer = null;
cubeNormalsBuffer.limit(0);
cubeNormalsBuffer = null;
cubeTextureCoordinatesBuffer.limit(0);
cubeTextureCoordinatesBuffer = null;
}
示例14: CubesWithVbo
import java.nio.FloatBuffer; //导入方法依赖的package包/类
CubesWithVbo(float[] cubePositions, float[] cubeNormals, float[] cubeTextureCoordinates, int generatedCubeFactor) {
FloatBuffer[] floatBuffers = getBuffers(cubePositions, cubeNormals, cubeTextureCoordinates, generatedCubeFactor);
FloatBuffer cubePositionsBuffer = floatBuffers[0];
FloatBuffer cubeNormalsBuffer = floatBuffers[1];
FloatBuffer cubeTextureCoordinatesBuffer = floatBuffers[2];
// Second, copy these buffers into OpenGL's memory. After, we don't need to keep the client-side buffers around.
final int buffers[] = new int[3];
GLES20.glGenBuffers(3, buffers, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, cubePositionsBuffer.capacity() * BYTES_PER_FLOAT, cubePositionsBuffer, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[1]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, cubeNormalsBuffer.capacity() * BYTES_PER_FLOAT, cubeNormalsBuffer, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[2]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, cubeTextureCoordinatesBuffer.capacity() * BYTES_PER_FLOAT, cubeTextureCoordinatesBuffer,
GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
mCubePositionsBufferIdx = buffers[0];
mCubeNormalsBufferIdx = buffers[1];
mCubeTexCoordsBufferIdx = buffers[2];
cubePositionsBuffer.limit(0);
cubePositionsBuffer = null;
cubeNormalsBuffer.limit(0);
cubeNormalsBuffer = null;
cubeTextureCoordinatesBuffer.limit(0);
cubeTextureCoordinatesBuffer = null;
}
示例15: createBuffers
import java.nio.FloatBuffer; //导入方法依赖的package包/类
/**
* create buffers for the Lines shape object
* @param linePositions
* @param lineColors
*/
public void createBuffers(float[] linePositions, float[] lineColors) {
final int lineDataLength = linePositions.length;
vertexCount = linePositions.length / POSITION_DATA_SIZE;
final FloatBuffer lineBuffer = ByteBuffer.allocateDirect(lineDataLength * BYTES_PER_FLOAT)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
lineBuffer.put(linePositions);
final FloatBuffer colorBuffer = ByteBuffer.allocateDirect(lineColors.length * BYTES_PER_FLOAT)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
colorBuffer.put(lineColors);
lineBuffer.position(0);
colorBuffer.position(0);
FloatBuffer linePositionsBuffer = lineBuffer;
FloatBuffer lineColorsBuffers = colorBuffer;
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, glLineBuffer[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, linePositionsBuffer.capacity() * BYTES_PER_FLOAT, linePositionsBuffer, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, glLineBuffer[1]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, lineColorsBuffers.capacity() * BYTES_PER_FLOAT, lineColorsBuffers, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
aLinePositionsBufferIdx = glLineBuffer[0];
aLineColorsBufferIdx = glLineBuffer[1];
linePositionsBuffer.limit(0);
linePositionsBuffer = null;
lineColorsBuffers.limit(0);
lineColorsBuffers = null;
}