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

The following examples show how to use javax.microedition.khronos.opengles.GL10#glScalef() . 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: 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 2
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 3
Source File: KubeRenderer.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
public void onDrawFrame(GL10 gl) {
     if (mCallback != null) {
         mCallback.animate();
     }

    /*
     * Usually, the first thing one might want to do is to clear
     * the screen. The most efficient way of doing this is to use
     * glClear(). However we must make sure to set the scissor
     * correctly first. The scissor is always specified in window
     * coordinates:
     */

    gl.glClearColor(0.5f,0.5f,0.5f,1);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

    /*
     * Now we're ready to draw some 3D object
     */

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();
    gl.glTranslatef(0, 0, -3.0f);
    gl.glScalef(0.5f, 0.5f, 0.5f);
    gl.glRotatef(mAngle,        0, 1, 0);
    gl.glRotatef(mAngle*0.25f,  1, 0, 0);

    gl.glColor4f(0.7f, 0.7f, 0.7f, 1.0f);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glShadeModel(GL10.GL_SMOOTH);
    gl.glEnable(GL10.GL_DEPTH_TEST);

    mWorld.draw(gl);
}
 
Example 4
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);
    }