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

The following examples show how to use javax.microedition.khronos.opengles.GL10#glDisable() . 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: CubeRenderer.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    /*
     * By default, OpenGL enables features that improve quality
     * but reduce performance. One might want to tweak that
     * especially on software renderer.
     */
    gl.glDisable(GL10.GL_DITHER);

    /*
     * Some one-time OpenGL initialization can be made here
     * probably based on features of this particular context
     */
     gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,
             GL10.GL_FASTEST);

     if (mTranslucentBackground) {
         gl.glClearColor(0,0,0,0);
     } else {
         gl.glClearColor(1,1,1,1);
     }
     gl.glEnable(GL10.GL_CULL_FACE);
     gl.glShadeModel(GL10.GL_SMOOTH);
     gl.glEnable(GL10.GL_DEPTH_TEST);
}
 
Example 2
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 3
Source File: TouchRotateActivity.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    /*
     * By default, OpenGL enables features that improve quality
     * but reduce performance. One might want to tweak that
     * especially on software renderer.
     */
    gl.glDisable(GL10.GL_DITHER);

    /*
     * Some one-time OpenGL initialization can be made here
     * probably based on features of this particular context
     */
     gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,
             GL10.GL_FASTEST);


     gl.glClearColor(1,1,1,1);
     gl.glEnable(GL10.GL_CULL_FACE);
     gl.glShadeModel(GL10.GL_SMOOTH);
     gl.glEnable(GL10.GL_DEPTH_TEST);
}
 
Example 4
Source File: PLCylindricalPanorama.java    From PanoramaGL with Apache License 2.0 5 votes vote down vote up
/**render methods*/

@Override
protected void internalRender(GL10 gl, PLIRenderer renderer)
{
	PLITexture previewTexture = this.getPreviewTextures()[0], texture = this.getTextures()[0];
	
    boolean textureIsValid = (texture != null && texture.getTextureId(gl) != 0);
    
    if(textureIsValid || (previewTexture != null && previewTexture.getTextureId(gl) != 0))
    {
    	gl.glEnable(GL10.GL_TEXTURE_2D);
    	
    	int divs;
 		
 		if(textureIsValid)
 	    {
 	    	divs = this.getDivs();
 	        gl.glBindTexture(GL10.GL_TEXTURE_2D, texture.getTextureId(gl));
 	        if(previewTexture != null)
	            this.removePreviewTextureAtIndex(0, true);
 	    }
 		else
 	    {
 	    	divs = this.getPreviewDivs();
 	        gl.glBindTexture(GL10.GL_TEXTURE_2D, previewTexture.getTextureId(gl));
 	    }
 		
 	    gl.glTranslatef(0.0f, 0.0f, -mHalfHeight);
 		
 	    GLUES.gluCylinder(gl, this.getQuadric(), PLConstants.kPanoramaRadius, PLConstants.kPanoramaRadius, mHeight, divs, divs);
 		
 	    gl.glTranslatef(0.0f, 0.0f, mHalfHeight);
 		
 	    gl.glDisable(GL10.GL_TEXTURE_2D);
    }
}
 
Example 5
Source File: TexCubeSmallGLUT.java    From opengl with Apache License 2.0 5 votes vote down vote up
void draw(GL10 gl) {
if (texEnabled) {
    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mCoordBuffer);
}

super.draw(gl);

if (texEnabled) {
    gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glDisable(GL10.GL_TEXTURE_2D);
}
   }
 
Example 6
Source File: LightingRenderer.java    From augmentedreality with Apache License 2.0 5 votes vote down vote up
public final void initGL(GL10 gl) {
	gl.glDisable(GL10.GL_COLOR_MATERIAL);
	gl.glShadeModel(GL10.GL_SMOOTH);
	gl.glEnable(GL10.GL_LIGHTING);
	//gl.glEnable(GL10.GL_CULL_FACE);
	gl.glEnable(GL10.GL_DEPTH_TEST);
	gl.glEnable(GL10.GL_NORMALIZE);
	gl.glEnable(GL10.GL_RESCALE_NORMAL);
}
 
Example 7
Source File: SquareRenderer.java    From opengl with Apache License 2.0 5 votes vote down vote up
public void onSurfaceCreated(GL10 gl, EGLConfig config) {//15
	gl.glDisable(GL10.GL_DITHER); //16
	gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, //17
			GL10.GL_FASTEST);
	if (mTranslucentBackground) {//18
		gl.glClearColor(0,0,0,0);
	} else {
		gl.glClearColor(1,1,1,1);
	}
	gl.glEnable(GL10.GL_CULL_FACE); //19
	gl.glShadeModel(GL10.GL_SMOOTH); //20
	gl.glEnable(GL10.GL_DEPTH_TEST); //21
}
 
Example 8
Source File: OpenGLRenderer.java    From smartGL with Apache License 2.0 5 votes vote down vote up
private void checkDoubleSided(GL10 gl) {
    if (mDoubleSided != null) {
        if (mDoubleSided.booleanValue()) {
            gl.glDisable(GL10.GL_CULL_FACE);
        } else {
            gl.glEnable(GL10.GL_CULL_FACE);
            gl.glCullFace(GL10.GL_FRONT);
        }
        mDoubleSided = null;    // applied
    }
}
 
Example 9
Source File: TouchSurfaceView.java    From retrobreaker with MIT License 5 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
	gl.glDisable(GL10.GL_DITHER);
	gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST);

	gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	gl.glDisable(GL10.GL_CULL_FACE);
	gl.glShadeModel(GL10.GL_SMOOTH);
	gl.glDisable(GL10.GL_DEPTH_TEST);
}
 
Example 10
Source File: TexCubeSmallGLUT.java    From opengl with Apache License 2.0 5 votes vote down vote up
void draw(GL10 gl) {
if (texEnabled) {
    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mCoordBuffer);
}

super.draw(gl);

if (texEnabled) {
    gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glDisable(GL10.GL_TEXTURE_2D);
}
   }
 
Example 11
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 12
Source File: FrameBufferObjectActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
private void drawOffscreenImage(GL10 gl, int width, int height) {
    gl.glViewport(0, 0, width, height);
    float ratio = (float) width / height;
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();
    gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);

    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glEnable(GL10.GL_DEPTH_TEST);

    gl.glClearColor(0,0.5f,1,0);
    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(mAngle,        0, 1, 0);
    gl.glRotatef(mAngle*0.25f,  1, 0, 0);

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

    mCube.draw(gl);

    gl.glRotatef(mAngle*2.0f, 0, 1, 1);
    gl.glTranslatef(0.5f, 0.5f, 0.5f);

    mCube.draw(gl);

    mAngle += 1.2f;

    // Restore default state so the other renderer is not affected.

    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_DEPTH_TEST);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
}
 
Example 13
Source File: TriangleRenderer.java    From codeexamples-android with Eclipse Public License 1.0 4 votes vote down vote up
public void onDrawFrame(GL10 gl) {
    /*
     * By default, OpenGL enables features that improve quality
     * but reduce performance. One might want to tweak that
     * especially on software renderer.
     */
    gl.glDisable(GL10.GL_DITHER);

    gl.glTexEnvx(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE,
            GL10.GL_MODULATE);

    /*
     * 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().
     */

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

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

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

    GLU.gluLookAt(gl, 0, 0, -5, 0f, 0f, 0f, 0f, 1.0f, 0.0f);

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

    gl.glActiveTexture(GL10.GL_TEXTURE0);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID);
    gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,
            GL10.GL_REPEAT);
    gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,
            GL10.GL_REPEAT);

    long time = SystemClock.uptimeMillis() % 4000L;
    float angle = 0.090f * ((int) time);

    gl.glRotatef(angle, 0, 0, 1.0f);

    mTriangle.draw(gl);
}
 
Example 14
Source File: OpenGLRenderer.java    From smartGL with Apache License 2.0 4 votes vote down vote up
@Override
public void onDrawFrame(GL10 gl10) {

    computeFps();

    GLES20.glClearColor(mClearColor[0], mClearColor[1], mClearColor[2], mClearColor[3]);    // RGBA
    GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);

    checkDoubleSided(gl10);

    synchronized (this) {

        if (!mInitDone) {
            return;
        }

        if (mOpenGLView != null) {
            OpenGLView view = mOpenGLView.get();
            if (view != null) {
                view.onPreRender(this);
            }
        }

        if ((mCamera != null) && mCamera.isDirty()) {
            computeProjMatrix3D(mProj3DMatrix);
        }

        onPreRender(gl10);

        if (mRenderPasses != null) {

            int passNumber = 0;
            final int prgSize = mRenderPasses.size();
            for (int prgIt = 0; prgIt < prgSize; ++prgIt) {
                final RenderPass renderPass = mRenderPasses.get(prgIt);
                if (!renderPass.isLoaded()) {
                    renderPass.load();
                }

                renderPass.sortObjects();

                ++passNumber;
                onPreRenderPass(gl10, passNumber);

                Vector<RenderObject> mainObjectList = renderPass.getRenderObjects();
                //Vector<RenderObject> objectList = buildObjectList(mainObjectList);	// recursive with Container Objects

                if (renderPass.useZBuffer()) {
                    gl10.glEnable(GL10.GL_DEPTH_TEST);
                    if (renderPass.clearZBuffer()) {
                        GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT);
                    }
                } else {
                    gl10.glDisable(GL10.GL_DEPTH_TEST);
                }

                mPreviousShader = null;
                mUseTexture = false;
                mUseColor = false;
                mVertexAttribId = -1;
                mUvAttribId = -1;
                mColorAttribId = -1;
                mProjMatrixId = -1;

                // OBJECTS
                for (int renderObjIt = 0; renderObjIt < mainObjectList.size(); ++renderObjIt) {
                    RenderObject object = mainObjectList.get(renderObjIt);
                    boolean render = object.shouldDisplay(this);
                    if (object.isContainer()) {
                        renderContainer(renderPass, (RenderObjectContainer) object, render);
                    } else {
                        renderObject(renderPass, object, render);
                    }

                }

                onPostRenderPass(gl10, passNumber);
            }
        }
        //handleTouchEvents();
        onPostRender(gl10);

        if (mScreenshotListener != null) {
            doTakeScreenshot(gl10);
        }
    }

}
 
Example 15
Source File: CubeMapActivity.java    From codeexamples-android with Eclipse Public License 1.0 4 votes vote down vote up
public void onDrawFrame(GL10 gl) {
    checkGLError(gl);
    if (mContextSupportsCubeMap) {
        gl.glClearColor(0,0,1,0);
    } else {
        // Current context doesn't support cube maps.
        // Indicate this by drawing a red background.
        gl.glClearColor(1,0,0,0);
    }
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();

    GLU.gluLookAt(gl, 0, 0, -5, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
    gl.glRotatef(mAngle,        0, 1, 0);
    gl.glRotatef(mAngle*0.25f,  1, 0, 0);

    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

    checkGLError(gl);

    if (mContextSupportsCubeMap) {
        gl.glActiveTexture(GL10.GL_TEXTURE0);
        checkGLError(gl);
        gl.glEnable(GL11ExtensionPack.GL_TEXTURE_CUBE_MAP);
        checkGLError(gl);
        gl.glBindTexture(GL11ExtensionPack.GL_TEXTURE_CUBE_MAP, mCubeMapTextureID);
        checkGLError(gl);
        GL11ExtensionPack gl11ep = (GL11ExtensionPack) gl;
        gl11ep.glTexGeni(GL11ExtensionPack.GL_TEXTURE_GEN_STR,
                GL11ExtensionPack.GL_TEXTURE_GEN_MODE,
                GL11ExtensionPack.GL_REFLECTION_MAP);
        checkGLError(gl);
        gl.glEnable(GL11ExtensionPack.GL_TEXTURE_GEN_STR);
        checkGLError(gl);
        gl.glTexEnvx(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_DECAL);
    }

    checkGLError(gl);
    mGrid.draw(gl);

    if (mContextSupportsCubeMap) {
        gl.glDisable(GL11ExtensionPack.GL_TEXTURE_GEN_STR);
    }
    checkGLError(gl);

    mAngle += 1.2f;
}
 
Example 16
Source File: PLSpherical2Panorama.java    From PanoramaGL with Apache License 2.0 4 votes vote down vote up
/**render methods*/

@Override
protected void internalRender(GL10 gl, PLIRenderer renderer)
{
	PLITexture previewTexture = this.getPreviewTextures()[0];
	PLITexture[] textures = this.getTextures();
	PLITexture frontTexture = textures[PLSpherical2FaceOrientation.PLSpherical2FaceOrientationFront.ordinal()];
	PLITexture backTexture = textures[PLSpherical2FaceOrientation.PLSpherical2FaceOrientationBack.ordinal()];
	PLITexture leftTexture = textures[PLSpherical2FaceOrientation.PLSpherical2FaceOrientationLeft.ordinal()];
	PLITexture rightTexture = textures[PLSpherical2FaceOrientation.PLSpherical2FaceOrientationRight.ordinal()];
	
    boolean frontTextureIsValid = (frontTexture != null && frontTexture.getTextureId(gl) != 0);
    boolean backTextureIsValid = (backTexture != null && backTexture.getTextureId(gl) != 0);
    boolean leftTextureIsValid = (leftTexture != null && leftTexture.getTextureId(gl) != 0);
    boolean rightTextureIsValid = (rightTexture != null && rightTexture.getTextureId(gl) != 0);
    
    if(frontTextureIsValid || backTextureIsValid || leftTextureIsValid || rightTextureIsValid || (previewTexture != null && previewTexture.getTextureId(gl) != 0))
    {
    	gl.glEnable(GL10.GL_TEXTURE_2D);
    	
    	GLUquadric quadratic = this.getQuadric();
	    float radius = PLConstants.kPanoramaRadius;
	    int halfDivs = this.getDivs() / 2, quarterDivs = halfDivs / 2;
	    
	    if(previewTexture != null)
	    {
	        if(frontTextureIsValid && backTextureIsValid && leftTextureIsValid && rightTextureIsValid)
	            this.removePreviewTextureAtIndex(0, true);
	        else
	        {
	        	int previewDivs = this.getPreviewDivs();
	            gl.glBindTexture(GL10.GL_TEXTURE_2D, previewTexture.getTextureId(gl));
	            GLUES.gluSphere(gl, quadratic, radius, previewDivs, previewDivs);
	        }
	    }
	    
	    // Front Face
	    if(frontTextureIsValid)
	    {
	        gl.glBindTexture(GL10.GL_TEXTURE_2D, frontTexture.getTextureId(gl));
	        GLUES.glu3DArc(gl, quadratic, PLConstants.kPI8, -PLConstants.kPI16, false, radius, quarterDivs, quarterDivs);
	    }
	    
	    // Back Face
	    if(backTextureIsValid)
	    {
	        gl.glBindTexture(GL10.GL_TEXTURE_2D, backTexture.getTextureId(gl));
	        GLUES.glu3DArc(gl, quadratic, PLConstants.kPI8, -PLConstants.kPI16, true, radius, quarterDivs, quarterDivs);
	    }
	    
	    // Left Face
	    if(leftTextureIsValid)
	    {
	        gl.glBindTexture(GL10.GL_TEXTURE_2D, leftTexture.getTextureId(gl));
	        GLUES.gluHemisphere(gl, quadratic, false, radius, halfDivs, halfDivs);
	    }
	    
	    //Right Face
	    if(rightTextureIsValid)
	    {
	        gl.glBindTexture(GL10.GL_TEXTURE_2D, rightTexture.getTextureId(gl));
	        GLUES.gluHemisphere(gl, quadratic, true, radius, halfDivs, halfDivs);
	    }
	    
		gl.glDisable(GL10.GL_TEXTURE_2D);
    }
}
 
Example 17
Source File: MatrixPaletteRenderer.java    From codeexamples-android with Eclipse Public License 1.0 4 votes vote down vote up
public void onDrawFrame(GL10 gl) {
    /*
     * By default, OpenGL enables features that improve quality
     * but reduce performance. One might want to tweak that
     * especially on software renderer.
     */
    gl.glDisable(GL10.GL_DITHER);

    gl.glTexEnvx(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE,
            GL10.GL_MODULATE);

    /*
     * 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().
     */

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

    gl.glEnable(GL10.GL_DEPTH_TEST);

    gl.glEnable(GL10.GL_CULL_FACE);

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

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

    GLU.gluLookAt(gl, 0, 0, -5, 0f, 0f, 0f, 0f, 1.0f, 0.0f);

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

    gl.glActiveTexture(GL10.GL_TEXTURE0);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID);
    gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,
            GL10.GL_REPEAT);
    gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,
            GL10.GL_REPEAT);

    long time = SystemClock.uptimeMillis() % 4000L;

    // Rock back and forth
    double animationUnit = ((double) time) / 4000;
    float unitAngle = (float) Math.cos(animationUnit * 2 * Math.PI);
    float angle = unitAngle * 135f;

    gl.glEnable(GL11Ext.GL_MATRIX_PALETTE_OES);
    gl.glMatrixMode(GL11Ext.GL_MATRIX_PALETTE_OES);

    GL11Ext gl11Ext = (GL11Ext) gl;

    // matrix 0: no transformation
    gl11Ext.glCurrentPaletteMatrixOES(0);
    gl11Ext.glLoadPaletteFromModelViewMatrixOES();


    // matrix 1: rotate by "angle"
    gl.glRotatef(angle, 0, 0, 1.0f);

    gl11Ext.glCurrentPaletteMatrixOES(1);
    gl11Ext.glLoadPaletteFromModelViewMatrixOES();

    mGrid.draw(gl);

    gl.glDisable(GL11Ext.GL_MATRIX_PALETTE_OES);
}
 
Example 18
Source File: PLRenderableElementBase.java    From panoramagl with Apache License 2.0 4 votes vote down vote up
protected void endAlpha(GL10 gl) {
    gl.glDisable(GL10.GL_BLEND);
    gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
 
Example 19
Source File: TriangleRenderer.java    From codeexamples-android with Eclipse Public License 1.0 4 votes vote down vote up
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    /*
     * By default, OpenGL enables features that improve quality
     * but reduce performance. One might want to tweak that
     * especially on software renderer.
     */
    gl.glDisable(GL10.GL_DITHER);

    /*
     * Some one-time OpenGL initialization can be made here
     * probably based on features of this particular context
     */
    gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,
            GL10.GL_FASTEST);

    gl.glClearColor(.5f, .5f, .5f, 1);
    gl.glShadeModel(GL10.GL_SMOOTH);
    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glEnable(GL10.GL_TEXTURE_2D);

    /*
     * Create our texture. This has to be done each time the
     * surface is created.
     */

    int[] textures = new int[1];
    gl.glGenTextures(1, textures, 0);

    mTextureID = textures[0];
    gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID);

    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,
            GL10.GL_NEAREST);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D,
            GL10.GL_TEXTURE_MAG_FILTER,
            GL10.GL_LINEAR);

    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,
            GL10.GL_CLAMP_TO_EDGE);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,
            GL10.GL_CLAMP_TO_EDGE);

    gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE,
            GL10.GL_REPLACE);

    InputStream is = mContext.getResources()
            .openRawResource(R.raw.robot);
    Bitmap bitmap;
    try {
        bitmap = BitmapFactory.decodeStream(is);
    } finally {
        try {
            is.close();
        } catch(IOException e) {
            // Ignore.
        }
    }

    GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
    bitmap.recycle();
}
 
Example 20
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);
}