Package java.nio

Examples of java.nio.FloatBuffer


        LwjglRendererUtil.switchMode(matRecord, GL11.GL_MODELVIEW);
        GL11.glPopMatrix();
    }

    public void setupVertexData(final FloatBufferData vertexBufferData) {
        final FloatBuffer vertexBuffer = vertexBufferData != null ? vertexBufferData.getBuffer() : null;

        if (vertexBuffer == null) {
            GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
        } else {
            GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
            vertexBuffer.rewind();
            GL11.glVertexPointer(vertexBufferData.getValuesPerTuple(), 0, vertexBuffer);
        }
    }
View Full Code Here


            GL11.glVertexPointer(vertexBufferData.getValuesPerTuple(), 0, vertexBuffer);
        }
    }

    public void setupNormalData(final FloatBufferData normalBufferData) {
        final FloatBuffer normalBuffer = normalBufferData != null ? normalBufferData.getBuffer() : null;

        if (normalBuffer == null) {
            GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
        } else {
            GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
            normalBuffer.rewind();
            GL11.glNormalPointer(0, normalBuffer);
        }
    }
View Full Code Here

            GL11.glNormalPointer(0, normalBuffer);
        }
    }

    public void setupColorData(final FloatBufferData colorBufferData) {
        final FloatBuffer colorBuffer = colorBufferData != null ? colorBufferData.getBuffer() : null;

        if (colorBuffer == null) {
            GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
        } else {
            GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
            colorBuffer.rewind();
            GL11.glColorPointer(colorBufferData.getValuesPerTuple(), 0, colorBuffer);
        }
    }
View Full Code Here

            GL11.glColorPointer(colorBufferData.getValuesPerTuple(), 0, colorBuffer);
        }
    }

    public void setupFogData(final FloatBufferData fogBufferData) {
        final FloatBuffer fogBuffer = fogBufferData != null ? fogBufferData.getBuffer() : null;

        if (fogBuffer == null) {
            GL11.glDisableClientState(EXTFogCoord.GL_FOG_COORDINATE_ARRAY_EXT);
        } else {
            GL11.glEnableClientState(EXTFogCoord.GL_FOG_COORDINATE_ARRAY_EXT);
            fogBuffer.rewind();
            EXTFogCoord.glFogCoordPointerEXT(0, fogBuffer);
        }
    }
View Full Code Here

                        // enable bit in tracking int
                        enabledTextures |= (2 << i);
                    }

                    final FloatBufferData textureBufferData = textureCoords.get(i);
                    final FloatBuffer textureBuffer = textureBufferData.getBuffer();

                    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
                    textureBuffer.rewind();
                    GL11.glTexCoordPointer(textureBufferData.getValuesPerTuple(), 0, textureBuffer);
                }
            }
        }
View Full Code Here

            final FloatBufferData vertexCoords, final FloatBufferData normalCoords, final FloatBufferData colorCoords,
            final List<FloatBufferData> textureCoords, final int bufferSize) {

        // keep around buffer size
        if (interleaved.getBufferCapacity() != 1) {
            final FloatBuffer buffer = BufferUtils.createFloatBufferOnHeap(1);
            interleaved.setBuffer(buffer);
        }
        interleaved.getBuffer().rewind();
        interleaved.getBuffer().put(bufferSize);

        final RendererRecord rendRecord = context.getRendererRecord();
        final ContextCapabilities caps = context.getCapabilities();

        final int vboID = makeVBOId();
        interleaved.setVBOID(context.getGlContextRep(), vboID);

        rendRecord.invalidateVBO();
        LwjglRendererUtil.setBoundVBO(rendRecord, vboID);
        ARBBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, bufferSize,
                getGLVBOAccessMode(interleaved.getVboAccessMode()));

        int offsetBytes = 0;
        if (normalCoords != null) {
            normalCoords.getBuffer().rewind();
            ARBBufferObject.glBufferSubDataARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, offsetBytes,
                    normalCoords.getBuffer());
            offsetBytes += normalCoords.getBufferLimit() * 4;
        }
        if (colorCoords != null) {
            colorCoords.getBuffer().rewind();
            ARBBufferObject.glBufferSubDataARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, offsetBytes,
                    colorCoords.getBuffer());
            offsetBytes += colorCoords.getBufferLimit() * 4;
        }
        if (textureCoords != null) {
            final TextureState ts = (TextureState) context.getCurrentState(RenderState.StateType.Texture);
            if (ts != null) {
                for (int i = 0; i <= ts.getMaxTextureIndexUsed() && i < caps.getNumberOfFragmentTexCoordUnits(); i++) {
                    if (textureCoords == null || i >= textureCoords.size()) {
                        continue;
                    }

                    final FloatBufferData textureBufferData = textureCoords.get(i);
                    final FloatBuffer textureBuffer = textureBufferData != null ? textureBufferData.getBuffer() : null;
                    if (textureBuffer != null) {
                        textureBuffer.rewind();
                        ARBBufferObject.glBufferSubDataARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, offsetBytes,
                                textureBuffer);
                        offsetBytes += textureBufferData.getBufferLimit() * 4;
                    }
                }
View Full Code Here

    public FloatBuffer getProjectionMatrix(final FloatBuffer store) {
        return getMatrix(GL11.GL_PROJECTION_MATRIX, store);
    }

    private FloatBuffer getMatrix(final int matrixType, final FloatBuffer store) {
        FloatBuffer result = store;
        if (result.remaining() < 16) {
            result = BufferUtils.createFloatBuffer(16);
        }
        GL11.glGetFloat(matrixType, store);
        return result;
    }
View Full Code Here

    frustum[side][2] /= magnitude;
    frustum[side][3] /= magnitude;
  }

  public void calculateFrustum(GL gl) {
    FloatBuffer fbproj = FloatBuffer.allocate(16);
    FloatBuffer fbmodl = FloatBuffer.allocate(16);

    gl.glGetFloatv(GL.GL_PROJECTION_MATRIX, fbproj);

    gl.glGetFloatv(GL.GL_MODELVIEW_MATRIX, fbmodl);

    float proj[] = fbproj.array();
    float modl[] = fbmodl.array();

    // multiply modl*proj to get resulting view matrix

    clip[0] = modl[0] * proj[0] + modl[1] * proj[4] + modl[2] * proj[8]
        + modl[3] * proj[12];
 
View Full Code Here

    List<MapTileTreeNode> selectedNodes = new ArrayList<MapTileTreeNode>();

    MapTileTreeNode currentNode = mtt.getRootNode();

    /* get the current projection and modelview matrix for visibility checking */
    FloatBuffer projection = FloatBuffer.allocate(16);
    gl.glGetFloatv(GL.GL_PROJECTION_MATRIX, projection);
    FloatBuffer modelview = FloatBuffer.allocate(16);
    gl.glGetFloatv(GL.GL_MODELVIEW_MATRIX, modelview);

    /* get the resulting matrix */
    Matrix pm = new Matrix(projection);
    Matrix projmodelmatrix = pm.multiply(new Matrix(modelview));
View Full Code Here

  }

  public static void drawClothAsPatches(DBody[][] bodymatrix) {
    GL11.glEnable(GL11.GL_LIGHTING);

    FloatBuffer fb1 = BufferUtils.createFloatBuffer(4);
    fb1.put(new float[] { .8f, .0f, 1.f, 1.f }).flip();
    GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT, fb1);
    GL11.glMaterial(GL11.GL_FRONT, GL11.GL_DIFFUSE, fb1);

    FloatBuffer fb2 = BufferUtils.createFloatBuffer(4);
    fb2.put(new float[] { .8f, .8f, 0f, 1.f }).flip();
    GL11.glMaterial(GL11.GL_BACK, GL11.GL_AMBIENT, fb2);
    GL11.glMaterial(GL11.GL_BACK, GL11.GL_DIFFUSE, fb2);

    GL11.glLightModeli(GL11.GL_LIGHT_MODEL_TWO_SIDE, GL11.GL_TRUE);
    GL11.glFrontFace(GL11.GL_CW);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_MAP2_VERTEX_3);
    GL11.glEnable(GL11.GL_AUTO_NORMAL);

    // Extract control points

    int size = bodymatrix.length;
    FloatBuffer pos = BufferUtils.createFloatBuffer(bodymatrix.length
        * bodymatrix.length * 3);

    for (int i = 0; i < bodymatrix.length; i++) {
      for (int j = 0; j < bodymatrix.length; j++) {
        DVector3C vec0 = bodymatrix[i][j].getPosition();
        float[] f0 = vec0.toFloatArray();
        pos.put(f0);
      }
    }
    pos.rewind();

    GL11.glMap2f(GL11.GL_MAP2_VERTEX_3, 0, 1, size * 3, size, 0, 1, 3,
        size, pos);
    GL11.glMapGrid2f(40, 0, 1, 40, 0, 1);
    GL11.glEvalMesh2(GL11.GL_FILL, 0, 40, 0, 40);
View Full Code Here

TOP

Related Classes of java.nio.FloatBuffer

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.