Java 类java.nio.FloatBuffer 实例源码

项目:TeamProject    文件:AudioEngine.java   
/**
 * (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();
}
项目:cocos2d-java    文件:GLView.java   
/**
 * 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);
}
项目:BaseClient    文件:Shaders.java   
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");
}
项目:Ultraino    文件:BufferUtils.java   
/**
 * 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;
}
项目:jtk    文件:EllipsoidGlyph.java   
/**
 * 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());
}
项目:BitmapFontLoader    文件:Bitmap3DCharTest.java   
@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());
}
项目:Tower-Defense-Galaxy    文件:VRContext.java   
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);
}
项目:openjdk-jdk10    文件:ByteBufferViews.java   
@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);
    }

}
项目:multiple-dimension-spread    文件:DumpFloatColumnBinaryMaker.java   
@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 );
}
项目:BaseClient    文件:OpenGlHelper.java   
public static void glUniformMatrix3(int location, boolean transpose, FloatBuffer matrices)
{
    if (arbShaders)
    {
        ARBShaderObjects.glUniformMatrix3ARB(location, transpose, matrices);
    }
    else
    {
        GL20.glUniformMatrix3(location, transpose, matrices);
    }
}
项目:Backmemed    文件:OpenGlHelper.java   
public static void glUniform4(int location, FloatBuffer values)
{
    if (arbShaders)
    {
        ARBShaderObjects.glUniform4ARB(location, values);
    }
    else
    {
        GL20.glUniform4(location, values);
    }
}
项目:Ultraino    文件:BufferUtils.java   
/**
 * 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;
}
项目:BaseClient    文件:OpenGlHelper.java   
public static void glUniform3(int location, FloatBuffer values)
{
    if (arbShaders)
    {
        ARBShaderObjects.glUniform3ARB(location, values);
    }
    else
    {
        GL20.glUniform3(location, values);
    }
}
项目:TeamProject    文件:AudioEngine.java   
/**
 * (Probably don't use this unless you have a really specific reason!)
 * Create an AudioEngine with custom position, velocity and orientation for the listener.
 * @param listenerPos Custom position of the listener - (Float, Float, Float)
 * @param listenerVel Custom velocity of the listener - (Float, Float, Float)
 * @param listenerOri Custom orientation of the listener - (Float, Float, Float, Float, Float, Float)
 *                    First three floats - "at"; Second three Floats - "up".
 */
private AudioEngine(FloatBuffer listenerPos, FloatBuffer listenerVel, FloatBuffer listenerOri) {
    setDeviceAndContext();

    this.listenerPos = listenerPos;
    this.listenerVel = listenerVel;
    this.listenerOri = listenerOri;

    setListenerValues();
}
项目:AppRTC-Android    文件:GlUtil.java   
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;
}
项目:EcoSystem-Official    文件:Vao.java   
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;
}
项目:OpenGL-Bullet-engine    文件:DynamicModel.java   
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;
}
项目:CustomWorldGen    文件:OpenGlHelper.java   
public static void glUniform4(int location, FloatBuffer values)
{
    if (arbShaders)
    {
        ARBShaderObjects.glUniform4ARB(location, values);
    }
    else
    {
        GL20.glUniform4(location, values);
    }
}
项目:CommunityEngine-Java    文件:Util.java   
public static FloatBuffer flip(float[] data) {
    FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
    buffer.put(data);
    buffer.flip();

    return buffer;
}
项目:jaer    文件:DavisFrameAviWriter.java   
@Override
    synchronized public void propertyChange(PropertyChangeEvent evt) {
        if ((aviOutputStream != null && isWriteEnabled())
                && (evt.getPropertyName() == AEFrameChipRenderer.EVENT_NEW_FRAME_AVAILBLE)
                && !chip.getAeViewer().isPaused()) {
            FloatBuffer frame = ((AEFrameChipRenderer)chip.getRenderer()).getPixmap();

            BufferedImage bufferedImage = new BufferedImage(chip.getSizeX(), chip.getSizeY(), BufferedImage.TYPE_3BYTE_BGR);
            WritableRaster raster = bufferedImage.getRaster();
            int sx = chip.getSizeX(), sy = chip.getSizeY();
            for (int y = 0; y < sy; y++) {
                for (int x = 0; x < sx; x++) {
                    int k = renderer.getPixMapIndex(x, y);
//                    bufferedImage.setRGB(x, y, (int) (frame[k] * 1024));
                    int yy = sy - y - 1;
                    int r = (int) (frame.get(k) * 255); // must flip image vertially according to java convention that image starts at upper left
                    int g = (int) (frame.get(k+1) * 255); // must flip image vertially according to java convention that image starts at upper left
                    int b = (int) (frame.get(k+2) * 255); // must flip image vertially according to java convention that image starts at upper left
                    raster.setSample(x, yy, 0, r);
                    raster.setSample(x, yy, 1, g);
                    raster.setSample(x, yy, 2, b);
                }
            }
            try {
                aviOutputStream.writeFrame(bufferedImage);
                int timestamp = renderer.getTimestampFrameEnd();
                writeTimecode(timestamp);
                incrementFramecountAndMaybeCloseOutput();

            } catch (IOException ex) {
                Logger.getLogger(DavisFrameAviWriter.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else if (evt.getPropertyName() == AEInputStream.EVENT_REWIND) {
            doCloseFile();
        }
    }
项目:Backmemed    文件:Shaders.java   
public static void setProgramUniformMatrix4ARB(String name, boolean transpose, FloatBuffer matrix)
{
    int i = programsID[activeProgram];

    if (i != 0 && matrix != null)
    {
        int j = ARBShaderObjects.glGetUniformLocationARB(i, (CharSequence)name);
        ARBShaderObjects.glUniformMatrix4ARB(j, transpose, matrix);
        checkGLError(programNames[activeProgram], name);
    }
}
项目:aos-MediaLib    文件:MatrixTrackingGL.java   
public void glMultMatrixf(FloatBuffer m) {
    int position = m.position();
    mCurrent.glMultMatrixf(m);
    m.position(position);
    mgl.glMultMatrixf(m);
    if ( _check) check();
}
项目:Ultraino    文件:BoundingSphere.java   
/**
 * Calculates a minimum bounding sphere for the copyTo of points. The algorithm
 * was originally found in C++ at
 * <p><a href="http://www.flipcode.com/cgi-bin/msg.cgi?showThread=COTD-SmallestEnclosingSpheres&forum=cotd&id=-1">
 * http://www.flipcode.com/cgi-bin/msg.cgi?showThread=COTD-SmallestEnclosingSpheres&forum=cotd&id=-1</a><br><strong>broken link</strong></p>
 * <p>and translated to java by Cep21</p>
 *
 * @param points
 *            The points to calculate the minimum bounds from.
 */
public void calcWelzl(FloatBuffer points) {
    if (center == null) {
        center = new Vector3f();
    }
    FloatBuffer buf = BufferUtils.createFloatBuffer(points.limit());
    points.rewind();
    buf.put(points);
    buf.flip();
    recurseMini(buf, buf.limit() / 3, 0, 0);
}
项目:openjdk-jdk10    文件:BufferIndexingLinkerExporter.java   
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;
}
项目:Backmemed    文件:OpenGlHelper.java   
public static void glUniform3(int location, FloatBuffer values)
{
    if (arbShaders)
    {
        ARBShaderObjects.glUniform3ARB(location, values);
    }
    else
    {
        GL20.glUniform3(location, values);
    }
}
项目:mao-android    文件:CameraFilterGroup.java   
@SuppressLint("WrongCall")
@Override
public void onDraw(final int textureId, final FloatBuffer cubeBuffer, final FloatBuffer textureBuffer) {
    runPendingOnDrawTasks();
    if (!isInitialized() || mFrameBuffers == null || mFrameBufferTextures == null) {
        return;
    }
    if (mMergedFilters != null) {
        int size = mMergedFilters.size();
        int previousTexture = textureId;
        for (int i = 0; i < size; i++) {
            CameraFilter filter = mMergedFilters.get(i);
            boolean isNotLast = i < size - 1;
            if (isNotLast) {
                GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFrameBuffers[i]);
                GLES20.glClearColor(0, 0, 0, 0);
            }

            if (i == 0) {
                filter.onDraw(previousTexture, cubeBuffer, textureBuffer);
            } else if (i == size - 1) {
                filter.onDraw(previousTexture, mGLCubeBuffer, (size % 2 == 0) ? mGLTextureFlipBuffer : mGLTextureBuffer);
            } else {
                filter.onDraw(previousTexture, mGLCubeBuffer, mGLTextureBuffer);
            }

            if (isNotLast) {
                GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
                previousTexture = mFrameBufferTextures[i];
            }
        }
    }
 }
项目:SquareOne    文件:TexturedMesh.java   
/**
 * Update UV mapping data
 * @param data UV mapping data
 */
public void updateCoords(float[] data) {
    FloatBuffer buf = Buffers.createFloatBuffer(data);
    glBindBuffer(GL_ARRAY_BUFFER, vCoords);
    glBufferData(GL_ARRAY_BUFFER, buf, GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
}
项目:jaer    文件:Chip2DRenderer.java   
/**
 * Subclasses should call checkPixmapAllocation to make sure the pixmap
 * FloatBuffer is allocated before accessing it.
 *
 */
protected void checkPixmapAllocation() {
    final int n = 3 * chip.getNumPixels();
    if ((pixmap == null) || (pixmap.capacity() < n)) {
        pixmap = FloatBuffer.allocate(n); // Buffers.newDirectFloatBuffer(n);
    }
}
项目:EZFilter    文件:BitmapInput.java   
/**
 * BitmapInput和AbstractRender设置的纹理顶点坐标是倒置的关系
 */
@Override
protected void initTextureVertices() {
    mTextureVertices = new FloatBuffer[4];

    // (0,0) -------> (1,0)
    //     ^
    //      \\
    //        \\
    //          \\
    //            \\
    // (0,1) -------> (1,1)
    float[] texData0 = new float[]{0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f,
            1.0f, 0.0f,};
    mTextureVertices[0] = ByteBuffer.allocateDirect(texData0.length * 4)
            .order(ByteOrder.nativeOrder()).asFloatBuffer();
    mTextureVertices[0].put(texData0).position(0);

    float[] texData1 = new float[]{0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f,
            1.0f, 1.0f,};
    mTextureVertices[1] = ByteBuffer.allocateDirect(texData1.length * 4)
            .order(ByteOrder.nativeOrder()).asFloatBuffer();
    mTextureVertices[1].put(texData1).position(0);

    float[] texData2 = new float[]{1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f,
            0.0f, 1.0f,};
    mTextureVertices[2] = ByteBuffer.allocateDirect(texData2.length * 4)
            .order(ByteOrder.nativeOrder()).asFloatBuffer();
    mTextureVertices[2].put(texData2).position(0);

    float[] texData3 = new float[]{1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
            0.0f, 0.0f,};
    mTextureVertices[3] = ByteBuffer.allocateDirect(texData3.length * 4)
            .order(ByteOrder.nativeOrder()).asFloatBuffer();
    mTextureVertices[3].put(texData3).position(0);
}
项目:BaseClient    文件:Graphics.java   
/**
 * Get the current graphics context background color
 * 
 * @return The background color of this graphics context
 */
public Color getBackground() {
    predraw();
    FloatBuffer buffer = BufferUtils.createFloatBuffer(16);
    GL.glGetFloat(SGL.GL_COLOR_CLEAR_VALUE, buffer);
    postdraw();

    return new Color(buffer);
}
项目:Backmemed    文件:OpenGlHelper.java   
public static void glUniformMatrix3(int location, boolean transpose, FloatBuffer matrices)
{
    if (arbShaders)
    {
        ARBShaderObjects.glUniformMatrix3ARB(location, transpose, matrices);
    }
    else
    {
        GL20.glUniformMatrix3(location, transpose, matrices);
    }
}
项目:libRtmp    文件:AndroidUntil.java   
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;
}
项目:SbCamera    文件:GlUtil.java   
/**
 * 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;
}
项目:FilterPlayer    文件:GPUImageFilter.java   
protected void setFloatVec4(final int location, final float[] arrayValue) {
    runOnDraw(new Runnable() {
        @Override
        public void run() {
            GLES20.glUniform4fv(location, 1, FloatBuffer.wrap(arrayValue));
        }
    });
}
项目:19porn    文件:OpenGlUtils.java   
public static FloatBuffer createFloatBuffer(double[] coords) {
    float buffer[] = new float[coords.length];
    for (int i = 0; i < buffer.length; i++) {
        buffer[i] = (float)(coords[i]);
    }
    // Allocate a direct ByteBuffer, using 4 bytes per float, and copy coords into it.
    ByteBuffer bb = ByteBuffer.allocateDirect(buffer.length * SIZEOF_FLOAT);
    bb.order(ByteOrder.nativeOrder());
    FloatBuffer fb = bb.asFloatBuffer();
    fb.put(buffer);
    fb.position(0);
    return fb;
}
项目:poly-sample-android    文件:MyGLUtils.java   
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];
}
项目:19porn    文件:GPUImageFilter.java   
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();
    }

}
项目:UNIST-pixel-dungeon    文件:NoosaScript.java   
public void drawQuad( FloatBuffer vertices ) {

    vertices.position( 0 );
    aXY.vertexPointer( 2, 4, vertices );

    vertices.position( 2 );
    aUV.vertexPointer( 2, 4, vertices );

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE, GLES20.GL_UNSIGNED_SHORT, 0 );
    } else {
        FroyoGLES20Fix.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE, GLES20.GL_UNSIGNED_SHORT, 0 );
    }

}
项目:debug    文件:ARBBufferStorage.java   
public static void glBufferStorage(int target, FloatBuffer data, int flags) {
    org.lwjgl.opengl.ARBBufferStorage.glBufferStorage(target, data, flags);
    if (Properties.PROFILE.enabled) {
        Context ctx = CURRENT_CONTEXT.get();
        BufferObject bo = ctx.bufferObjectBindings.get(target);
        if (bo != null) {
            bo.size = data != null ? data.remaining() << 2 : 0L;
        }
    }
}
项目:MediaCodecRecorder    文件:GLUtil.java   
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;
}