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

The following examples show how to use javax.microedition.khronos.opengles.GL10#glDrawArrays() . 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: WaveformVisualizerSurfaceView.java    From android-openslmediaplayer with Apache License 2.0 6 votes vote down vote up
private static void drawWaveForm(
        GL10 gl, int width, int height,
        FloatBuffer vertices, int n, float ymin, float ymax, FloatColor color) {

    gl.glPushMatrix();

    // viewport
    gl.glViewport(0, 0, width, height);

    // X: [0:1], Y: [ymin:ymax]
    gl.glOrthof(0.0f, 1.0f, ymin, ymax, -1.0f, 1.0f);

    gl.glColor4f(color.red, color.green, color.blue, color.alpha);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glVertexPointer(2, GL10.GL_FLOAT, (2 * Float.SIZE / 8), vertices);
    gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, n);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

    gl.glPopMatrix();
}
 
Example 2
Source File: Quad.java    From retrobreaker with MIT License 6 votes vote down vote up
public void draw(GL10 gl) {
	gl.glMatrixMode(GL10.GL_MODELVIEW);
	gl.glPushMatrix();
	gl.glLoadIdentity();
	gl.glTranslatef(mPosX, mPosY, 0.0f);
	gl.glScalef(mScale, mScale, mScale);

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

	gl.glVertexPointer(2, GL10.GL_FLOAT, 0, mVertexBuffer);
	gl.glColorPointer(4, GL10.GL_FLOAT, 0, mColorBuffer);

	gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);

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

	gl.glPopMatrix();
}
 
Example 3
Source File: FftVisualizerSurfaceView.java    From android-openslmediaplayer with Apache License 2.0 6 votes vote down vote up
private static void drawFFT(
        GL10 gl, int width, int height,
        FloatBuffer vertices, int n,
        float yrange, FloatColor color) {

    gl.glPushMatrix();

    // viewport
    gl.glViewport(0, 0, width, height);

    // X: [0:1], Y: [0:yrange]
    gl.glOrthof(0.0f, 1.0f, 0.0f, yrange, -1.0f, 1.0f);

    gl.glColor4f(color.red, color.green, color.blue, color.alpha);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glVertexPointer(2, GL10.GL_FLOAT, (2 * Float.SIZE / 8), vertices);
    gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, n);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

    gl.glPopMatrix();
}
 
Example 4
Source File: HQWaveformVisualizerSurfaceView.java    From android-openslmediaplayer with Apache License 2.0 6 votes vote down vote up
private static void drawWaveForm(
        GL10 gl, int width, int height,
        FloatBuffer vertices, int n, int vposition, float yrange, FloatColor color) {

    gl.glPushMatrix();

    // viewport
    gl.glViewport(0, (height / 2) * (1 - vposition), width, (height / 2));

    // X: [0:1], Y: [-1:+1] (scaled)
    gl.glOrthof(0.0f, 1.0f, -yrange, yrange, -1.0f, 1.0f);

    gl.glColor4f(color.red, color.green, color.blue, color.alpha);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glVertexPointer(2, GL10.GL_FLOAT, (2 * Float.SIZE / 8), vertices);
    gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, n);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

    gl.glPopMatrix();
}
 
Example 5
Source File: HQFftVisualizerSurfaceView.java    From android-openslmediaplayer with Apache License 2.0 6 votes vote down vote up
private static void drawFFT(
        GL10 gl, int width, int height,
        FloatBuffer vertices, int n,
        int vposition, float yrange, FloatColor color) {

    gl.glPushMatrix();

    // viewport
    gl.glViewport(0, (height / 2) * (1 - vposition), width, (height / 2));

    // X: [0:1], Y: [0:1]
    gl.glOrthof(0.0f, 1.0f, 0.0f, yrange, -1.0f, 1.0f);

    gl.glColor4f(color.red, color.green, color.blue, color.alpha);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glVertexPointer(2, GL10.GL_FLOAT, (2 * Float.SIZE / 8), vertices);
    gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, n);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

    gl.glPopMatrix();
}
 
Example 6
Source File: GLBitmap.java    From TikTok with Apache License 2.0 6 votes vote down vote up
public void draw(GL10 gl) {
    // bind the previously generated texture
    gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);

    // Point to our buffers
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

    // Set the face rotation
    gl.glFrontFace(GL10.GL_CW);

    // Point to our vertex buffer
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);

    // Draw the vertices as triangle strip
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);

    // Disable the client state before leaving
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
}
 
Example 7
Source File: GLVertexList.java    From homescreenarcade with GNU General Public License v3.0 6 votes vote down vote up
public void render(GL10 gl) {
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    if (colorIndex>4) {
        gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
    }
    else {
        gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
    }

    gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertexBuffer);
    if (colorIndex>4) {
        gl.glColorPointer(4, GL10.GL_FLOAT, 0, colorBuffer);
    }
    else if (colorIndex==4) {
        // single color
        gl.glColor4f(
                colorComponents[0], colorComponents[1], colorComponents[2], colorComponents[3]);
    }

    gl.glDrawArrays(glMode, 0, numVertices);
}
 
Example 8
Source File: PLHotspot.java    From panoramagl with Apache License 2.0 5 votes vote down vote up
/**
 * render methods
 */

@Override
protected void internalRender(GL10 gl, PLIRenderer renderer) {
    this.calculateCoords(gl);

    List<PLITexture> textures = this.getTextures();
    int textureId = (textures.size() > 0 ? textures.get(0).getTextureId(gl) : 0);
    if (textureId == 0 || mVertexsBuffer == null || mTextureCoordsBuffer == null)
        return;

    gl.glEnable(GL10.GL_TEXTURE_2D);

    PLIView view = renderer.getInternalView();
    gl.glColor4f(1.0f, 1.0f, 1.0f, (view != null && view.isValidForTransition()) || this.getTouchStatus() == PLSceneElementTouchStatus.PLSceneElementTouchStatusOut ? this.getAlpha() : mOverAlpha);

    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexsBuffer);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTextureCoordsBuffer);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glCullFace(GL10.GL_FRONT);
    gl.glShadeModel(GL10.GL_SMOOTH);

    gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId);

    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);

    gl.glDisable(GL10.GL_TEXTURE_2D);
    gl.glDisable(GL10.GL_BLEND);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
}
 
Example 9
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();
}
 
Example 10
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 11
Source File: TriangleSmallGLUT.java    From opengl with Apache License 2.0 5 votes vote down vote up
void draw(GL10 gl) {
    gl.glFrontFace(GL10.GL_CW);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);
    gl.glNormal3f(0f, 0f, 1f);
    
    gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3);
    
}
 
Example 12
Source File: TriangleSmallGLUT.java    From opengl with Apache License 2.0 5 votes vote down vote up
void draw(GL10 gl) {
    gl.glFrontFace(GL10.GL_CW);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);
    gl.glNormal3f(0f, 0f, 1f);
    
    gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3);
    
}
 
Example 13
Source File: TGAGLSurfaceView.java    From TGAReader with MIT License 5 votes vote down vote up
private void draw(GL10 gl, int texture) {
	
	gl.glEnable(GL_TEXTURE_2D);
	gl.glActiveTexture(GL_TEXTURE0);
	gl.glBindTexture(GL_TEXTURE_2D, texture);
	
	// front
	gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
	// back
	gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 4, 4);
	
	gl.glDisable(GL_TEXTURE_2D);
}
 
Example 14
Source File: GLRender.java    From LiveBlurListView with Apache License 2.0 4 votes vote down vote up
private void process(Bitmap bitmap, boolean fast) {
	final GL10 gl = mGL;
	
	gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	gl.glShadeModel(GL10.GL_SMOOTH);
	gl.glEnable(GL10.GL_DEPTH_TEST);
	gl.glClearDepthf(1.0f);
	gl.glDepthFunc(GL10.GL_LEQUAL);
	gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
	gl.glEnable(GL10.GL_TEXTURE_2D);
	gl.glEnable(GL10.GL_LEQUAL);
	
	float[] color = new float[16];
	FloatBuffer colorBuffer;
	float[] texVertex = new float[12];
	FloatBuffer vertexBuffer;
	
	ByteBuffer texByteBuffer = ByteBuffer.allocateDirect(texVertex.length * 4);
	texByteBuffer.order(ByteOrder.nativeOrder());
	vertexBuffer = texByteBuffer.asFloatBuffer();
	vertexBuffer.put(texVertex);
	vertexBuffer.position(0);
	
	ByteBuffer colorByteBuffer = ByteBuffer.allocateDirect(color.length * 4);
	colorByteBuffer.order(ByteOrder.nativeOrder());
	colorBuffer = colorByteBuffer.asFloatBuffer();
	colorBuffer.put(color);
	colorBuffer.position(0);
	
	gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
	gl.glPushMatrix();
	gl.glTranslatef(0.0f, 0.0f, 0.0f);
	

	
	colorBuffer.clear();
	colorBuffer.put(1.0f);
	colorBuffer.put(0.0f);
	colorBuffer.put(0.0f);
	colorBuffer.put(1.0f);
	
	colorBuffer.put(1.0f);
	colorBuffer.put(0.0f);
	colorBuffer.put(0.0f);
	colorBuffer.put(1.0f);
	
	colorBuffer.put(1.0f);
	colorBuffer.put(0.0f);
	colorBuffer.put(0.0f);
	colorBuffer.put(1.0f);
	
	colorBuffer.put(1.0f);
	colorBuffer.put(0.0f);
	colorBuffer.put(0.0f);
	colorBuffer.put(1.0f);
	
	vertexBuffer.clear();
	vertexBuffer.put(0);
	vertexBuffer.put(0);
	vertexBuffer.put(0);
	vertexBuffer.put(5f);
	vertexBuffer.put(0);
	vertexBuffer.put(0);
	vertexBuffer.put(5f);
	vertexBuffer.put(5f);
	vertexBuffer.put(0);
	vertexBuffer.put(0);
	vertexBuffer.put(5f);
	vertexBuffer.put(0);
	
	gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
	gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
	gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
	

	
	gl.glColorPointer(4, GL10.GL_FLOAT, 0, colorBuffer);
	
	gl.glDrawArrays(GL10.GL_LINE_LOOP, 0, 4);
	gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
	
	gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
	gl.glPopMatrix();
}
 
Example 15
Source File: PLCubicPanorama.java    From PanoramaGL with Apache License 2.0 4 votes vote down vote up
/**render methods*/

@Override
protected void internalRender(GL10 gl, PLIRenderer renderer)
{
	gl.glEnable(GL10.GL_TEXTURE_2D);
	
	gl.glEnable(GL10.GL_CULL_FACE);
	gl.glCullFace(GL10.GL_FRONT);
	gl.glShadeModel(GL10.GL_SMOOTH);
	
	gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
	gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
	gl.glVertexPointer(3, GL10.GL_FLOAT, 0, sCubeBuffer);
	gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, sTextureCoordsBuffer);
	
	// Front Face
	if(this.bindTextureByIndex(gl, PLConstants.kCubeFrontFaceIndex))
	{
		gl.glNormal3f(0.0f, 0.0f, 1.0f);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
	}
	
	// Back Face
	if(this.bindTextureByIndex(gl, PLConstants.kCubeBackFaceIndex))
	{
		gl.glNormal3f(0.0f, 0.0f, -1.0f);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 4, 4);
	}
	
	// Left Face
	if(this.bindTextureByIndex(gl, PLConstants.kCubeLeftFaceIndex))
	{
		gl.glNormal3f(1.0f, 0.0f, 0.0f);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 8, 4);
	}
	
	// Right Face
	if(this.bindTextureByIndex(gl, PLConstants.kCubeRightFaceIndex))
	{
		gl.glNormal3f(-1.0f, 0.0f, 0.0f);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 12, 4);
	}
	
	// Up Face
	if(this.bindTextureByIndex(gl, PLConstants.kCubeUpFaceIndex))
	{
		gl.glNormal3f(0.0f, 1.0f, 0.0f);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 16, 4);
	}
	
	// Down Face
	if(this.bindTextureByIndex(gl, PLConstants.kCubeDownFaceIndex))
	{
		gl.glNormal3f(0.0f, -1.0f, 0.0f);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 20, 4);
	}
	
	gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
	gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);	
	gl.glDisable(GL10.GL_CULL_FACE);
	gl.glDisable(GL10.GL_TEXTURE_2D);
}
 
Example 16
Source File: PLCubicPanorama.java    From panoramagl with Apache License 2.0 4 votes vote down vote up
/**
 * render methods
 */

@Override
protected void internalRender(GL10 gl, PLIRenderer renderer) {
    gl.glEnable(GL10.GL_TEXTURE_2D);

    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glCullFace(GL10.GL_FRONT);
    gl.glShadeModel(GL10.GL_SMOOTH);

    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, sCubeBuffer);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, sTextureCoordsBuffer);

    // Front Face
    if (this.bindTextureByIndex(gl, PLConstants.kCubeFrontFaceIndex)) {
        gl.glNormal3f(0.0f, 0.0f, 1.0f);
        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
    }

    // Back Face
    if (this.bindTextureByIndex(gl, PLConstants.kCubeBackFaceIndex)) {
        gl.glNormal3f(0.0f, 0.0f, -1.0f);
        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 4, 4);
    }

    // Left Face
    if (this.bindTextureByIndex(gl, PLConstants.kCubeLeftFaceIndex)) {
        gl.glNormal3f(1.0f, 0.0f, 0.0f);
        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 8, 4);
    }

    // Right Face
    if (this.bindTextureByIndex(gl, PLConstants.kCubeRightFaceIndex)) {
        gl.glNormal3f(-1.0f, 0.0f, 0.0f);
        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 12, 4);
    }

    // Up Face
    if (this.bindTextureByIndex(gl, PLConstants.kCubeUpFaceIndex)) {
        gl.glNormal3f(0.0f, 1.0f, 0.0f);
        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 16, 4);
    }

    // Down Face
    if (this.bindTextureByIndex(gl, PLConstants.kCubeDownFaceIndex)) {
        gl.glNormal3f(0.0f, -1.0f, 0.0f);
        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 20, 4);
    }

    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_TEXTURE_2D);
}
 
Example 17
Source File: LaserScanRenderer.java    From RobotCA with GNU General Public License v3.0 4 votes vote down vote up
private void drawWayPoints(GL10 gl) {

        FloatBuffer b;
        PointF res = new PointF();

        // Draw the waypoints
//        gl.glEnable(GL10.GL_DEPTH_TEST);
//        gl.glDepthFunc(GL10.GL_GEQUAL);

        // Lock on waypoints to prevent modifications while reading
        synchronized (controlApp.getWaypoints()) {

            b = Vertices.allocateBuffer(3 * controlApp.getWaypoints().size());
            b.rewind();

            for (Vector3 pt : controlApp.getWaypoints()) {

                drawPoint(gl, pt.getX(), pt.getY(), 0.0f, 0, res);

                b.put(res.x);
                b.put(res.y);
                b.put(0.0f);
            }
        }

        b.rewind();

        // Draw the path
        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

        gl.glLineWidth(8.0f);
        gl.glVertexPointer(3, GL10.GL_FLOAT, 3 * 4, b);
        gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, b.capacity() / 3);

        gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

//        gl.glDisable(GL10.GL_DEPTH_TEST);

        // Draw the Waypoints
        b.rewind();
        for (int i = 0; i < b.limit(); i += 3) {
            Utils.drawPoint(gl, b.get(i), b.get(i + 1), 24.0f,
                    i / 3 == movePtIdx ? 0xFFFFFF00: (i == 0 ? 0xFF22CC33 : 0xFF2233CC));

            if (i / 3 == movePtIdx)
            {
                Utils.drawPoint(gl, b.get(i), b.get(i + 1), 200.0f, 0x88FFFF00);
            }
        }
    }
 
Example 18
Source File: Graph3DRenderer.java    From ncalc with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onDrawFrame(GL10 gl) {
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();

    gl.glTranslatef(0, 0, -3.0f);
    gl.glRotatef(gamma, 0, 1f, 0);
    gl.glRotatef(alpha, 1f, 1f, 0);
    gl.glRotatef(beta, 0, 0, 1f);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

    if (dirty) {
        setUpArray();
        dirty = false;
    }

    gl.glLineWidth(1.0f);
    for (int k = 0; k < functions.size(); k++) {
        int colors[] = Graph2DView.colors[k];
        gl.glColor4f((float) colors[0] / 255, (float) colors[1] / 255, (float) colors[2], 1);
        for (int i = 0; i <= 30; i++) {
            vertexBuffer[k][i][1].position(0);
            gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer[k][i][0]);
            gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, 31);

            vertexBuffer[k][i][1].position(0);
            gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer[k][i][1]);
            gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, 31);
        }
    }

    gl.glLineWidth(3.0f);
    gl.glColor4f(1, 1, 1, 1);
    axisBuffer.position(0);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, axisBuffer);
    gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, axis.length);

    gl.glRotatef(gamma * 2.0f, 0, 0, 1);
    gl.glTranslatef(0.5f, 0.5f, 0.5f);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    long newSeconds = System.currentTimeMillis();

    if (!userRotate) {
        gamma += .04f * (newSeconds - milliseconds);
    }
    milliseconds = newSeconds;

}
 
Example 19
Source File: Planet.java    From opengl with Apache License 2.0 3 votes vote down vote up
public void draw(GL10 gl) 
{
 	
	gl.glFrontFace(GL10.GL_CW);					
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, m_VertexData);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
	
	gl.glColorPointer(4, GL10.GL_FLOAT, 0, m_ColorData);		

    gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
    
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, (m_Slices+1)*2*(m_Stacks-1)+2);
}
 
Example 20
Source File: Planet.java    From opengl with Apache License 2.0 3 votes vote down vote up
public void draw(GL10 gl) 
{
 	
	gl.glFrontFace(GL10.GL_CW);					
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, m_VertexData);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
	
	gl.glColorPointer(4, GL10.GL_FLOAT, 0, m_ColorData);		

    gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
    
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, (m_Slices+1)*2*(m_Stacks-1)+2);
}