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

The following examples show how to use javax.microedition.khronos.opengles.GL10#glBlendFunc() . 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: BobRenderer.java    From BobEngine with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Set up the surface. <br />
 * <br />
 * This method will load the textures, enable effects we need, disable
 * effects we don't need, set up the client state for drawing the quads.
 */
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
	myOwner.getGraphicsHelper().handleGraphics((GL11) gl);             // Load textures for the view

	low = high = -1;

	gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);          // How to interpret transparency
	gl.glAlphaFunc(GL10.GL_GREATER, 0);
	gl.glEnable(GL10.GL_BLEND);                                        // Enable transparency
	gl.glEnable(GL10.GL_TEXTURE_2D);                                   // Enable Texture Mapping

	// Disable all the things we don't need.
	gl.glDisable(GL10.GL_DEPTH_TEST);
	gl.glDisable(GL10.GL_FOG);
	gl.glDisable(GL10.GL_LIGHTING);
	gl.glDisable(GL10.GL_STENCIL_TEST);
	gl.glDisable(GL10.GL_SCISSOR_TEST);
	gl.glDisable(GL10.GL_DITHER);
	gl.glDisable(GL10.GL_CULL_FACE);

	gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);                      // We will use vertex arrays for quad vertices
	gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);               // We will need to use portions of textures
}
 
Example 2
Source File: LabelMaker.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Begin drawing labels. Sets the OpenGL state for rapid drawing.
 *
 * @param gl
 * @param viewWidth
 * @param viewHeight
 */
public void beginDrawing(GL10 gl, float viewWidth, float viewHeight) {
    checkState(STATE_INITIALIZED, STATE_DRAWING);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID);
    gl.glShadeModel(GL10.GL_FLAT);
    gl.glEnable(GL10.GL_BLEND);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    gl.glColor4x(0x10000, 0x10000, 0x10000, 0x10000);
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    gl.glOrthof(0.0f, viewWidth, 0.0f, viewHeight, 0.0f, 1.0f);
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    // Magic offsets to promote consistent rasterization.
    gl.glTranslatef(0.375f, 0.375f, 0.0f);
}
 
Example 3
Source File: GLFieldView.java    From homescreenarcade with GNU General Public License v3.0 5 votes vote down vote up
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    gl.glClearColor(0.0f, 0.0f, 0.0f, 1);
    gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST);
    gl.glShadeModel(GL10.GL_FLAT);
    gl.glDisable(GL10.GL_DEPTH_TEST);

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

    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();

    GLU.gluOrtho2D(gl, 0, getWidth(), getHeight(), 0);
}
 
Example 4
Source File: PLRenderableElementBase.java    From PanoramaGL with Apache License 2.0 5 votes vote down vote up
/**alpha methods*/

protected void beginAlpha(GL10 gl)
{
	gl.glEnable(GL10.GL_BLEND);
	gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
	gl.glColor4f(1.0f, 1.0f, 1.0f, this.getAlpha());
}
 
Example 5
Source File: PLRenderableElementBase.java    From panoramagl with Apache License 2.0 5 votes vote down vote up
/**
 * alpha methods
 */

protected void beginAlpha(GL10 gl) {
    gl.glEnable(GL10.GL_BLEND);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    gl.glColor4f(1.0f, 1.0f, 1.0f, this.getAlpha());
}
 
Example 6
Source File: Renderer.java    From augmentedreality with Apache License 2.0 5 votes vote down vote up
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
	gl.glClearColor(1,1,1,1);
	
	gl.glClearDepthf(1.0f);
	gl.glEnable(GL10.GL_DEPTH_TEST);
	gl.glDepthFunc(GL10.GL_LEQUAL);
	
	gl.glEnable(GL10.GL_TEXTURE_2D);

	gl.glShadeModel(GL10.GL_SMOOTH);
	gl.glDisable(GL10.GL_COLOR_MATERIAL);
	gl.glEnable(GL10.GL_BLEND);
	gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
	gl.glEnable(GL10.GL_LIGHTING);
	float[] ambientlight = {.6f, .6f, .6f, 1f};
	float[] diffuselight = {1f, 1f, 1f, 1f};
	float[] specularlight = {1f, 1f, 1f, 1f};
	gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_AMBIENT, MemUtil.makeFloatBuffer(ambientlight));
	gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, MemUtil.makeFloatBuffer(diffuselight));
	gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_SPECULAR, MemUtil.makeFloatBuffer(specularlight));
	gl.glEnable(GL10.GL_LIGHT0);
	
	for (Iterator<Model3D> iterator = models.iterator(); iterator.hasNext();) {
		Model3D model = iterator.next();
		model.init(gl);
	}
	
}
 
Example 7
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);
    }