Package java.nio

Examples of java.nio.Buffer


    public Mesh createMesh(Vector3f scale, Vector2f tcScale, Vector2f tcOffset, float offsetAmount, int totalSize, boolean center, int lod, boolean rightLod, boolean topLod, boolean leftLod, boolean bottomLod) {
        FloatBuffer pb = writeVertexArray(null, scale, center);
        FloatBuffer texb = writeTexCoordArray(null, tcOffset, tcScale, offsetAmount, totalSize);
        FloatBuffer nb = writeNormalArray(null, scale);
        Buffer ib;
        IndexBuffer idxB = writeIndexArrayLodDiff(lod, rightLod, topLod, leftLod, bottomLod, totalSize);
        if (idxB.getBuffer() instanceof IntBuffer)
            ib = (IntBuffer)idxB.getBuffer();
        else
            ib = (ShortBuffer)idxB.getBuffer();
View Full Code Here


        for (int i = 0; i < compsForBuf.length; i++) {
            if (compsForBuf[i] == 0) {
                continue;
            }

            Buffer data;
            if (i == Type.Index.ordinal()) {
                data = VertexBuffer.createBuffer(formatForBuf[i], compsForBuf[i], totalTris);
            } else {
                data = VertexBuffer.createBuffer(formatForBuf[i], compsForBuf[i], totalVerts);
            }
View Full Code Here

                }
            }

            if (geometry.getMesh().getMode() == Mode.Triangles) {// there is no need to flip the indexes for lines and points
                LOGGER.finer("Flipping index order in triangle mesh.");
                Buffer indexBuffer = geometry.getMesh().getBuffer(Type.Index).getData();
                for (int i = 0; i < indexBuffer.limit(); i += 3) {
                    if (indexBuffer instanceof ShortBuffer) {
                        short index = ((ShortBuffer) indexBuffer).get(i + 1);
                        ((ShortBuffer) indexBuffer).put(i + 1, ((ShortBuffer) indexBuffer).get(i + 2));
                        ((ShortBuffer) indexBuffer).put(i + 2, index);
                    } else {
View Full Code Here

    public void generateLodEntropies() {
        float[] entropies = new float[getMaxLod()+1];
        for (int i = 0; i <= getMaxLod(); i++){
            int curLod = (int) Math.pow(2, i);
            IndexBuffer idxB = geomap.writeIndexArrayLodDiff(curLod, false, false, false, false, totalSize);
            Buffer ib;
            if (idxB.getBuffer() instanceof IntBuffer)
                ib = (IntBuffer)idxB.getBuffer();
            else
                ib = (ShortBuffer)idxB.getBuffer();
            entropies[i] = EntropyComputeUtil.computeLodEntropy(mesh, ib);
View Full Code Here

            if (useVariableLod)
                idxB = geomap.writeIndexArrayLodVariable(pow, (int) Math.pow(2, utp.getRightLod()), (int) Math.pow(2, utp.getTopLod()), (int) Math.pow(2, utp.getLeftLod()), (int) Math.pow(2, utp.getBottomLod()), totalSize);
            else
                idxB = geomap.writeIndexArrayLodDiff(pow, right, top, left, bottom, totalSize);
           
            Buffer b;
            if (idxB.getBuffer() instanceof IntBuffer)
                b = (IntBuffer)idxB.getBuffer();
            else
                b = (ShortBuffer)idxB.getBuffer();
            utp.setNewIndexBuffer(b);
View Full Code Here

        bs.dbuffer = ((ByteBuffer)bs.buffer).asDoubleBuffer();
        bs.write();
    }
    public void testBufferFieldReadUnchanged() {
        BufferStructure bs = new BufferStructure();
        Buffer b = ByteBuffer.allocateDirect(16);
        bs.buffer = b;
        bs.dbuffer = ((ByteBuffer)bs.buffer).asDoubleBuffer();
        bs.write();
        bs.read();
        assertEquals("Buffer field should be unchanged", b, bs.buffer);
View Full Code Here

    }

    /* get the pointer to an extension array from indexes[index] */
    static Buffer ARRAY(ByteBuffer indexes, int index, Class itemType) {
        int oldpos = indexes.position();
        Buffer b;

        indexes.position(indexes.getInt(index << 2));
        if (itemType == int.class)
            b = indexes.asIntBuffer();
        else if (itemType == char.class)
View Full Code Here

/* 112 */     return this;
/*     */   }
/*     */
/*     */   public static int getBufferType(J3DBuffer b)
/*     */   {
/* 126 */     Buffer buffer = b.getBuffer();
/*     */     int bufferType;
/*     */     int bufferType;
/* 128 */     if (buffer == null) {
/* 129 */       bufferType = 0;
/*     */     }
View Full Code Here

        if (vboID != 0) {
            updateVBO(data, rendRecord, vboID, 0);
            return vboID;
        }

        final Buffer dataBuffer = data.getBuffer();
        if (dataBuffer != null) {
            // XXX: should we be rewinding? Maybe make that the programmer's responsibility.
            dataBuffer.rewind();
            vboID = makeVBOId();
            data.setVBOID(context.getGlContextRep(), vboID);

            rendRecord.invalidateVBO();
            JoglRendererUtil.setBoundVBO(rendRecord, vboID);
            gl.glBufferData(GL.GL_ARRAY_BUFFER, dataBuffer.limit() * data.getByteCount(), dataBuffer,
                    getGLVBOAccessMode(data.getVboAccessMode()));
        } else {
            throw new Ardor3dException("Attempting to create a vbo id for an AbstractBufferData with no Buffer value.");
        }
        return vboID;
View Full Code Here

    private static void updateVBO(final AbstractBufferData<? extends Buffer> data, final RendererRecord rendRecord,
            final int vboID, final int offsetBytes) {
        if (data.isNeedsRefresh()) {
            final GL gl = GLContext.getCurrentGL();
            final Buffer dataBuffer = data.getBuffer();
            dataBuffer.rewind();
            JoglRendererUtil.setBoundVBO(rendRecord, vboID);
            gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offsetBytes, dataBuffer.limit() * data.getByteCount(), dataBuffer);
            data.setNeedsRefresh(false);
        }
    }
View Full Code Here

TOP

Related Classes of java.nio.Buffer

Copyright © 2018 www.massapicom. 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.