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

The following examples show how to use javax.microedition.khronos.opengles.GL10#glPopMatrix() . 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: 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 3
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 4
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 5
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 6
Source File: Utils.java    From RobotCA with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the robot indicator shape.
 * @param gl The GL10 on which to draw
 * @param color The color
 */
public static void drawShape(GL10 gl, org.ros.android.view.visualization.Color color) {
    shape.rewind();

    gl.glPushMatrix();
    gl.glScalef(3.0f, 3.0f, 1.0f);
    Vertices.drawTriangleFan(gl, shape, color);
    gl.glPopMatrix();
}
 
Example 7
Source File: PageRenderer.java    From PlayLikeCurl with MIT License 5 votes vote down vote up
public void onDrawFrame(GL10 gl) {

		gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);	
		gl.glLoadIdentity();

		gl.glPushMatrix();
		gl.glTranslatef(0.0f, 0.0f, -2.0f);
		gl.glTranslatef(-0.5f, -0.5f, 0.0f);

		leftPage.draw(gl,context);
		gl.glPopMatrix();

		gl.glPushMatrix();
		gl.glTranslatef(0.0f, 0.0f, -2.0f);
		gl.glTranslatef(-0.5f, -0.5f, 0.0f);

		frontPage.draw(gl, context);
		gl.glPopMatrix();

		gl.glPushMatrix();
		gl.glTranslatef(0.0f, 0.0f, -2.0f);
		gl.glTranslatef(-0.5f, -0.5f, 0.0f);
		rightPage.draw(gl,context);

		gl.glPopMatrix();

	}
 
Example 8
Source File: CubeRenderer.java    From tilt-game-android with MIT License 5 votes vote down vote up
/**
 * Draws a translated cube
 * 
 * @param gl the surface
 * @param translateX x-translation
 * @param translateY y-translation
 * @param translateZ z-translation
 */
private void drawTranslatedCube(GL10 gl, float translateX, float translateY, float translateZ) {
    gl.glPushMatrix();
    gl.glTranslatef(translateX, translateY, translateZ);

    // draw our object
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

    mCube.draw(gl);
    gl.glPopMatrix();
}
 
Example 9
Source File: TGAGLSurfaceView.java    From TGAReader with MIT License 5 votes vote down vote up
@Override
public void onDrawFrame(GL10 gl) {
	gl.glClearColor(0.5f, 0.5f, 0.5f, 1);
	gl.glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
	
	gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
	gl.glVertexPointer(3, GL10.GL_FLOAT, 0, positionBuffer);

	gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
	gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, texcoordBuffer);
	
	gl.glEnable(GL_CULL_FACE);
	gl.glCullFace(GL_BACK);
	
	gl.glMatrixMode(GL10.GL_MODELVIEW);
	gl.glLoadIdentity();
	GLU.gluLookAt(gl, 3, 3, 3, 0, 0, 0, 0, 1, 0);
	
	// draw front and back
	draw(gl, tgaTextures[0]);
	
	// draw left and right
	gl.glPushMatrix();
	gl.glRotatef(90, 0, 1, 0);
	draw(gl, tgaTextures[1]);
	gl.glPopMatrix();
	
	// draw top and bottom
	gl.glPushMatrix();
	gl.glRotatef(-90, 1, 0, 0);
	draw(gl, tgaTextures[2]);
	gl.glPopMatrix();
}
 
Example 10
Source File: LabelMaker.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Ends the drawing and restores the OpenGL state.
 *
 * @param gl
 */
public void endDrawing(GL10 gl) {
    checkState(STATE_DRAWING, STATE_INITIALIZED);
    gl.glDisable(GL10.GL_BLEND);
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPopMatrix();
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPopMatrix();
}
 
Example 11
Source File: LaserScanRenderer.java    From RobotCA with GNU General Public License v3.0 4 votes vote down vote up
/**
     * Called to draw the current frame.
     * @param gl the GL interface.
     */
    @Override
    public void onDrawFrame(GL10 gl) {

        gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

        gl.glEnable(GL10.GL_BLEND);
        gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

        if (vertexFrontBuffer != null) {

            final float cameraX = xShift;
            final float cameraY = yShift;

            if (angleFollowsRobot)
                cameraAngle = 90.0f;
            else
                cameraAngle = angleShift + (float) Math.toDegrees(RobotController.getHeading());

            synchronized (mutex) {

                gl.glPushMatrix();

                // Adjust scale for screen aspect ratio
                gl.glScalef(cameraZoom * BASE_ZOOM / width, cameraZoom * BASE_ZOOM / height, 1f);

                // Apply camera translation
                gl.glTranslatef(cameraX, cameraY, 0.0f);

                // Rotate by the camera angle
                gl.glRotatef(cameraAngle, 0.0f, 0.0f, 1.0f);

                // Draw start position
                drawPoint(gl, 0.0, 0.0, 32.0f, 0xFFCCCCDD, null);

                // Draw the robot
                Utils.drawShape(gl, ROBOT_INDICATOR_COLOR);

                // Draw the scan area
                Utils.drawPoints(gl, vertexFrontBuffer, 0.0f, true);

//                // Draw the scanMap
//                ControlApp.getLaserScanMap().draw(gl, 8.0f, 0xFF22FF44);

                // Drop the first point which is required for the triangle fan but is
                // not a range reading.
                FloatBuffer pointVertices = vertexFrontBuffer.duplicate();
                pointVertices.position(3 + 4);

                // Draw the scan points
                Utils.drawPoints(gl, pointVertices, LASER_SCAN_POINT_SIZE, false);

                // Draw waypoints
                drawWayPoints(gl);

                // Reset transforms
                gl.glPopMatrix();
            }
        }

        gl.glDisable(GL10.GL_BLEND);
    }
 
Example 12
Source File: PLRenderableElementBase.java    From PanoramaGL with Apache License 2.0 4 votes vote down vote up
protected void endRender(GL10 gl, PLIRenderer renderer)
{
	this.endAlpha(gl);
	gl.glPopMatrix();
}
 
Example 13
Source File: PLRenderableElementBase.java    From panoramagl with Apache License 2.0 4 votes vote down vote up
protected void endRender(GL10 gl, PLIRenderer renderer) {
    this.endAlpha(gl);
    gl.glPopMatrix();
}
 
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();
}