Java Code Examples for javax.microedition.khronos.opengles.GL10#glPointSize()

The following examples show how to use javax.microedition.khronos.opengles.GL10#glPointSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java    From RobotCA with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws a point.
 * @param gl  The GL10 object for drawing
 * @param x The point's x coordinate
 * @param y The point's y coordinate
 * @param color The color in the form 0xAARRGGBB
 */
public static void drawPoint(GL10 gl, float x, float y, float size, int color) {

    fb.rewind();

    fb.put(x); // x
    fb.put(y); // y
    fb.put(0.0f); // z

    fb.put(Color.red(color) / 255.0f);   // r
    fb.put(Color.green(color) / 255.0f); // g
    fb.put(Color.blue(color) / 255.0f);  // b
    fb.put(Color.alpha(color) / 255.0f); // a

    fb.rewind();

    gl.glPointSize(size);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

    gl.glVertexPointer(3, GL10.GL_FLOAT, (3 + 4) * 4, fb);

    FloatBuffer colors = fb.duplicate();
    colors.position(3);
    gl.glColorPointer(4, GL10.GL_FLOAT, (3 + 4) * 4, colors);

    gl.glDrawArrays(GL10.GL_POINTS, 0, 1);

    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
}
 
Example 2
Source File: Utils.java    From RobotCA with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the contents of the specified buffer.
 *
 * @param gl       GL10 object for drawing
 * @param vertices FloatBuffer of vertices to draw
 * @param size     Size of draw points
 * @param fan      If true, draws the buffer as a triangle fan, otherwise draws it as a point cloud
 */
public static void drawPoints(GL10 gl, FloatBuffer vertices, float size, boolean fan) {
    vertices.mark();

    if (!fan)
        gl.glPointSize(size);

    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

    gl.glVertexPointer(3, GL10.GL_FLOAT, (3 + 4) * 4, vertices);

    FloatBuffer colors = vertices.duplicate();
    colors.position(fan ? 3 : 10);
    gl.glColorPointer(4, GL10.GL_FLOAT, (3 + 4) * 4, colors);

    gl.glDrawArrays(fan ? GL10.GL_TRIANGLE_FAN : GL10.GL_POINTS, 0, countVertices(vertices, 3 + 4));

    if (!fan) {
        gl.glDrawArrays(GL10.GL_POINTS, 0, countVertices(vertices, 3 + 4));
    }

    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

    vertices.reset();
}