Package java.nio

Examples of java.nio.FloatBuffer.flip()


      FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f});

      pos.flip();
      red.flip();
      green.flip();
      blue.flip();

      glLight(GL_LIGHT0, GL_POSITION, pos);
      glEnable(GL_CULL_FACE);
      glEnable(GL_LIGHTING);
      glEnable(GL_LIGHT0);
View Full Code Here


      } else {
        // --- using extensions
        final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put(
            new float[] { 1, 0, 0, 0, 0, 1, 0, 0,
              0, 0, 1, 0, 0, 0, 0, 1});
        identityTranspose.flip();
        glLoadTransposeMatrixARB(identityTranspose);
      }
      float h = (float) display_parent.getHeight() / (float) display_parent.getWidth();
      glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
      glMatrixMode(GL_MODELVIEW);
View Full Code Here

        // Iterate over all the points and store them in the FloatBuffer
        for (Point p : points) {
            vertexArray.put(new float[]{p.x, p.y, p.z});
        }
        // Make the buffer read-able for OpenGL
        vertexArray.flip();

        // Create the handle for the VBO
        int vertexBufferObject = glGenBuffers();
        // Bind the VBO for usage (in this case: storing information)
        glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObject);
View Full Code Here

            normals.put(BufferTools.asFloats(model.getNormals().get(face.getNormalIndices()[0] - 1)));
            normals.put(BufferTools.asFloats(model.getNormals().get(face.getNormalIndices()[1] - 1)));
            normals.put(BufferTools.asFloats(model.getNormals().get(face.getNormalIndices()[2] - 1)));
        }
        vertices.flip();
        normals.flip();
        glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
        glBufferData(GL_ARRAY_BUFFER, vertices, GL_STATIC_DRAW);
        glBindBuffer(GL_ARRAY_BUFFER, vboNormalHandle);
        glBufferData(GL_ARRAY_BUFFER, normals, GL_STATIC_DRAW);
        glBindBuffer(GL_ARRAY_BUFFER, 0);
View Full Code Here

        glColorMask(true, true, true, true);
        glDisable(GL_POLYGON_OFFSET_FILL);

        lightProjectionTemp.load(lightProjection);
        lightModelViewTemp.load(lightModelView);
        lightProjection.flip();
        lightModelView.flip();

        Matrix4f tempMatrix = new Matrix4f();
        tempMatrix.setIdentity();
        tempMatrix.translate(new Vector3f(0.5F, 0.5F, 0.5F));
View Full Code Here

                    * add an extra rendering pass.
                    */
            if (!ambientShadowsAvailable) {
                FloatBuffer lowAmbient = BufferUtils.createFloatBuffer(4);
                lowAmbient.put(new float[]{0.1F, 0.1F, 0.1F, 1.0F});
                lowAmbient.flip();

                FloatBuffer lowDiffuse = BufferUtils.createFloatBuffer(4);
                lowDiffuse.put(new float[]{0.35F, 0.35F, 0.35F, 1.0F});
                lowDiffuse.flip();

View Full Code Here

                lowAmbient.put(new float[]{0.1F, 0.1F, 0.1F, 1.0F});
                lowAmbient.flip();

                FloatBuffer lowDiffuse = BufferUtils.createFloatBuffer(4);
                lowDiffuse.put(new float[]{0.35F, 0.35F, 0.35F, 1.0F});
                lowDiffuse.flip();

                glLight(GL_LIGHT0, GL_AMBIENT, lowAmbient);
                glLight(GL_LIGHT0, GL_DIFFUSE, lowDiffuse);

                renderObjects(true);
View Full Code Here

            normals.put(asFloats(model.getNormals().get(face.getNormalIndices()[0] - 1)));
            normals.put(asFloats(model.getNormals().get(face.getNormalIndices()[1] - 1)));
            normals.put(asFloats(model.getNormals().get(face.getNormalIndices()[2] - 1)));
        }
        vertices.flip();
        normals.flip();
        glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
        glBufferData(GL_ARRAY_BUFFER, vertices, GL_STATIC_DRAW);
        glVertexPointer(3, GL_FLOAT, 0, 0L);
        glBindBuffer(GL_ARRAY_BUFFER, vboNormalHandle);
        glBufferData(GL_ARRAY_BUFFER, normals, GL_STATIC_DRAW);
View Full Code Here

     * @return a FloatBuffer representation of matrix4f
     */
    public static FloatBuffer asFlippedFloatBuffer(Matrix4f matrix4f) {
        FloatBuffer buffer = BufferUtils.createFloatBuffer(16);
        matrix4f.store(buffer);
        buffer.flip();
        return buffer;
    }

    /**
     * @param values the float values that are to be turned into a readable FloatBuffer
View Full Code Here

     * @return a FloatBuffer readable to OpenGL (not to you!) containing values
     */
    public static FloatBuffer asFlippedFloatBuffer(float... values) {
        FloatBuffer buffer = BufferUtils.createFloatBuffer(values.length);
        buffer.put(values);
        buffer.flip();
        return buffer;
    }
}
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.