本文整理匯總了Java中java.nio.FloatBuffer類的典型用法代碼示例。如果您正苦於以下問題:Java FloatBuffer類的具體用法?Java FloatBuffer怎麽用?Java FloatBuffer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FloatBuffer類屬於java.nio包,在下文中一共展示了FloatBuffer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: AudioEngine
import java.nio.FloatBuffer; //導入依賴的package包/類
/**
* (Use this as the default!)
* Create an AudioEngine with a static listener at the default location (0,0,0).
*/
private AudioEngine() {
setDeviceAndContext();
/**
* Set default values for the listener:
* listenerPos : 0.0f, 0.0f, 0.0f
* listenerVel : 0.0f, 0.0f, 0.0f
* listenerOri : 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f
*/
listenerPos = (FloatBuffer) BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).rewind();
listenerVel = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).rewind();
listenerOri =
(FloatBuffer)BufferUtils.createFloatBuffer(6).put(new float[] {0.0f,0.0f, -1.0f, 0.0f, 1.0f, 0.0f}).rewind();
setListenerValues();
}
示例2: getScissorRect
import java.nio.FloatBuffer; //導入依賴的package包/類
/**
* Get the current scissor rectangle
*/
public Rect getScissorRect() {
if(!Engine.instance().isGLThread()) {
// 不能在非gl線程中訪問
CCLog.error(TAG, "GLThread error");
return null;
}
FloatBuffer fb = BufferUtils.newFloatBuffer(16); //4 * 4
Gdx.gl.glGetFloatv(GL20.GL_SCISSOR_BOX, fb);
float[] params = new float[4];
fb.get(params);
float x = (params[0] - _viewPortRect.x) / _scaleX;
float y = (params[1] - _viewPortRect.y) / _scaleY;
float w = params[2] / _scaleX;
float h = params[3] / _scaleY;
return (Rect) poolRect.set(x, y, w, h);
}
示例3: setCamera
import java.nio.FloatBuffer; //導入依賴的package包/類
public static void setCamera(float partialTicks)
{
Entity entity = mc.getRenderViewEntity();
double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partialTicks;
double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partialTicks;
double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partialTicks;
cameraPositionX = d0;
cameraPositionY = d1;
cameraPositionZ = d2;
GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, (FloatBuffer)projection.position(0));
SMath.invertMat4FBFA((FloatBuffer)projectionInverse.position(0), (FloatBuffer)projection.position(0), faProjectionInverse, faProjection);
projection.position(0);
projectionInverse.position(0);
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, (FloatBuffer)modelView.position(0));
SMath.invertMat4FBFA((FloatBuffer)modelViewInverse.position(0), (FloatBuffer)modelView.position(0), faModelViewInverse, faModelView);
modelView.position(0);
modelViewInverse.position(0);
checkGLError("setCamera");
}
示例4: createFloatBuffer
import java.nio.FloatBuffer; //導入依賴的package包/類
/**
* Generate a new FloatBuffer using the given array of Vector2f objects.
* The FloatBuffer will be 2 * data.length long and contain the vector data
* as data[0].x, data[0].y, data[1].x... etc.
*
* @param data array of Vector2f objects to place into a new FloatBuffer
*/
public static FloatBuffer createFloatBuffer(Vector2f... data) {
if (data == null) {
return null;
}
FloatBuffer buff = createFloatBuffer(2 * data.length);
for (Vector2f element : data) {
if (element != null) {
buff.put(element.x).put(element.y);
} else {
buff.put(0).put(0);
}
}
buff.flip();
return buff;
}
示例5: draw
import java.nio.FloatBuffer; //導入依賴的package包/類
/**
* Draws a unit sphere centered at the origin.
*/
public void draw() {
if (_displayList==null) {
FloatBuffer xyz = Direct.newFloatBuffer(3*_nv);
xyz.put(_xyz); xyz.rewind();
_displayList = new GlDisplayList();
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glNewList(_displayList.list(),GL_COMPILE);
glVertexPointer(3,GL_FLOAT,0,xyz);
glNormalPointer(GL_FLOAT,0,xyz);
glDrawArrays(GL_TRIANGLES,0,_nv);
glEndList();
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
}
glCallList(_displayList.list());
}
示例6: testGetUvBuffer
import java.nio.FloatBuffer; //導入依賴的package包/類
@Test
public void testGetUvBuffer() throws Exception {
Bitmap3DChar o = new Bitmap3DChar(string3D, chr, 3);
FloatBuffer expected;
float[] uvs = {
o.getTopLeftU(), o.getTopLeftV(),
o.getBottomLeftU(), o.getBottomLeftV(),
o.getBottomRightU(), o.getBottomRightV(),
o.getTopRightU(), o.getTopRightV()
};
ByteBuffer ulb = ByteBuffer.allocateDirect(uvs.length * 4);
ulb.order(ByteOrder.nativeOrder());
expected = ulb.asFloatBuffer();
expected.put(uvs);
expected.position(0);
assertEquals(expected, o.getUvBuffer());
}
示例7: hmdMat4toMatrix4
import java.nio.FloatBuffer; //導入依賴的package包/類
static void hmdMat4toMatrix4(HmdMatrix44 hdm, Matrix4 mat) {
float[] val = mat.val;
FloatBuffer m = hdm.m();
val[0] = m.get(0);
val[1] = m.get(4);
val[2] = m.get(8);
val[3] = m.get(12);
val[4] = m.get(1);
val[5] = m.get(5);
val[6] = m.get(9);
val[7] = m.get(13);
val[8] = m.get(2);
val[9] = m.get(6);
val[10] = m.get(10);
val[11] = m.get(14);
val[12] = m.get(3);
val[13] = m.get(7);
val[14] = m.get(11);
val[15] = m.get(15);
}
示例8: testFloatGet
import java.nio.FloatBuffer; //導入依賴的package包/類
@Test(dataProvider = "floatViewProvider")
public void testFloatGet(String desc, IntFunction<ByteBuffer> fbb,
Function<ByteBuffer, FloatBuffer> fbi) {
ByteBuffer bb = allocate(fbb);
FloatBuffer vb = fbi.apply(bb);
int o = bb.position();
for (int i = 0; i < vb.limit(); i++) {
float fromBytes = getFloatFromBytes(bb, o + i * 4);
float fromMethodView = bb.getFloat(o + i * 4);
assertValues(i, fromBytes, fromMethodView, bb);
float fromBufferView = vb.get(i);
assertValues(i, fromMethodView, fromBufferView, bb, vb);
}
for (int i = 0; i < vb.limit(); i++) {
float v = getFloatFromBytes(bb, o + i * 4);
float a = bb.getFloat();
assertValues(i, v, a, bb);
float b = vb.get();
assertValues(i, a, b, bb, vb);
}
}
示例9: toBinary
import java.nio.FloatBuffer; //導入依賴的package包/類
@Override
public ColumnBinary toBinary(final ColumnBinaryMakerConfig commonConfig , final ColumnBinaryMakerCustomConfigNode currentConfigNode , final IColumn column ) throws IOException{
ColumnBinaryMakerConfig currentConfig = commonConfig;
if( currentConfigNode != null ){
currentConfig = currentConfigNode.getCurrentConfig();
}
byte[] binaryRaw = new byte[ getBinaryLength( column.size() ) ];
ByteBuffer lengthBuffer = ByteBuffer.wrap( binaryRaw );
lengthBuffer.putInt( column.size() );
lengthBuffer.putInt( column.size() * Float.BYTES );
ByteBuffer nullFlagBuffer = ByteBuffer.wrap( binaryRaw , Integer.BYTES * 2 , column.size() );
FloatBuffer floatBuffer = ByteBuffer.wrap( binaryRaw , ( Integer.BYTES * 2 + column.size() ) , ( column.size() * Float.BYTES ) ).asFloatBuffer();
int rowCount = 0;
for( int i = 0 ; i < column.size() ; i++ ){
ICell cell = column.get(i);
if( cell.getType() == ColumnType.NULL ){
nullFlagBuffer.put( (byte)1 );
floatBuffer.put( (float)0 );
}
else{
rowCount++;
PrimitiveCell byteCell = (PrimitiveCell) cell;
nullFlagBuffer.put( (byte)0 );
floatBuffer.put( byteCell.getRow().getFloat() );
}
}
byte[] binary = currentConfig.compressorClass.compress( binaryRaw , 0 , binaryRaw.length );
return new ColumnBinary( this.getClass().getName() , currentConfig.compressorClass.getClass().getName() , column.getColumnName() , ColumnType.FLOAT , rowCount , binaryRaw.length , rowCount * Float.BYTES , -1 , binary , 0 , binary.length , null );
}
示例10: glUniformMatrix3
import java.nio.FloatBuffer; //導入依賴的package包/類
public static void glUniformMatrix3(int location, boolean transpose, FloatBuffer matrices)
{
if (arbShaders)
{
ARBShaderObjects.glUniformMatrix3ARB(location, transpose, matrices);
}
else
{
GL20.glUniformMatrix3(location, transpose, matrices);
}
}
示例11: glUniform4
import java.nio.FloatBuffer; //導入依賴的package包/類
public static void glUniform4(int location, FloatBuffer values)
{
if (arbShaders)
{
ARBShaderObjects.glUniform4ARB(location, values);
}
else
{
GL20.glUniform4(location, values);
}
}
示例12: getVector3Array
import java.nio.FloatBuffer; //導入依賴的package包/類
/**
* Generates a Vector3f array from the given FloatBuffer.
*
* @param buff
* the FloatBuffer to read from
* @return a newly generated array of Vector3f objects
*/
public static Vector3f[] getVector3Array(FloatBuffer buff) {
buff.clear();
Vector3f[] verts = new Vector3f[buff.limit() / 3];
for (int x = 0; x < verts.length; x++) {
Vector3f v = new Vector3f(buff.get(), buff.get(), buff.get());
verts[x] = v;
}
return verts;
}
示例13: glUniform3
import java.nio.FloatBuffer; //導入依賴的package包/類
public static void glUniform3(int location, FloatBuffer values)
{
if (arbShaders)
{
ARBShaderObjects.glUniform3ARB(location, values);
}
else
{
GL20.glUniform3(location, values);
}
}
示例14: 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;
}
示例15: initDataFeed
import java.nio.FloatBuffer; //導入依賴的package包/類
public Vbo initDataFeed(FloatBuffer data, int usage, Attribute... newAttributes) {
int bytesPerVertex = getVertexDataTotalBytes(newAttributes);
Vbo vbo = Vbo.create(GL15.GL_ARRAY_BUFFER, usage);
relatedVbos.add(vbo);
vbo.allocateData(data.limit() * DataUtils.BYTES_IN_FLOAT);
vbo.storeData(0, data);
linkAttributes(bytesPerVertex, newAttributes);
vbo.unbind();
return vbo;
}