Package java.nio

Examples of java.nio.ByteBuffer.asFloatBuffer()


    }
    public void testFloatBufferGet() {
        final float MAGIC = 1234.5678f;
        Memory m = new Memory(8);
        ByteBuffer buf = m.getByteBuffer(0, m.getSize()).order(ByteOrder.nativeOrder());
        FloatBuffer fb = buf.asFloatBuffer();
        m.setFloat(0, MAGIC);
        assertEquals("Float not read from memory", MAGIC,
                fb.get(0));
    }
    public void testDoubleBufferGet() {
View Full Code Here


        assertEquals("IntBuffer Pointer does not match",
                     p, Native.getDirectBufferPointer(b.asIntBuffer()));
        assertEquals("LongBuffer Pointer does not match",
                     p, Native.getDirectBufferPointer(b.asLongBuffer()));
        assertEquals("FloatBuffer Pointer does not match",
                     p, Native.getDirectBufferPointer(b.asFloatBuffer()));
        assertEquals("DoubleBuffer Pointer does not match",
                     p, Native.getDirectBufferPointer(b.asDoubleBuffer()));

        assertEquals("Wrong direct buffer address",
                     p, Native.getDirectBufferPointer(b));
View Full Code Here

      //release the shader
      ARBShaderObjects.glUseProgramObjectARB(0);
    }
    ByteBuffer posbuff = ByteBuffer.allocateDirect(4*Float.SIZE/8);
    posbuff.putFloat(1.0f).putFloat(1.0f).putFloat(1.0f).putFloat(0.0f).flip();
    glLight(GL_LIGHT0, GL_POSITION, posbuff.asFloatBuffer());
    glEndList();

  }

  public void rotate(float x, float y, float z){
View Full Code Here

        vertexHandle = GL15.glGenBuffers();
        indiciesHandle = GL15.glGenBuffers();

        ByteBuffer verticesByteBuffer = BufferUtils.createByteBuffer(verticies.length * Vertex.getByteCount(Vertex.POSITION | Vertex.NORMAL | Vertex.COLOR));

        FloatBuffer verticesFloatBuffer = verticesByteBuffer.asFloatBuffer();
        for (int i = 0; i < verticies.length; i++) {
            verticies[i].get(Vertex.POSITION | Vertex.NORMAL | Vertex.COLOR, verticesFloatBuffer);
        }
        verticesFloatBuffer.rewind();

View Full Code Here

        GL30.glBindVertexArray(0);
    }

    private FloatBuffer convert(Vertex[] vertices) {
        ByteBuffer verticesByteBuffer = BufferUtils.createByteBuffer(vertices.length * Vertex.STRIDE);
        FloatBuffer verticesFloatBuffer = verticesByteBuffer.asFloatBuffer();
        for (int i = 0; i < vertices.length; i++) {
            verticesFloatBuffer.put(vertices[i].getElements());
        }
        verticesFloatBuffer.flip();
        return verticesFloatBuffer;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.