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

The following examples show how to use javax.microedition.khronos.opengles.GL10#glHint() . 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: Graph3DRenderer.java    From ncalc with GNU General Public License v3.0 6 votes vote down vote up
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    p = new Parser(Parser.STANDARD_FUNCTIONS | Parser.OPTIONAL_PARENS
            | Parser.OPTIONAL_STARS | Parser.OPTIONAL_SPACES
            | Parser.BRACES | Parser.BRACKETS);
    x = new Variable("x");
    y = new Variable("y");
    p.add(x);
    p.add(y);
    GraphMath.setUpParser(p);
    milliseconds = System.currentTimeMillis();
    importFunctions();
    gl.glDisable(GL10.GL_DITHER);
    gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST);
    gl.glClearColor(0, 0, 0, 1);
    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glShadeModel(GL10.GL_SMOOTH);
    gl.glEnable(GL10.GL_DEPTH_TEST);
}
 
Example 3
Source File: FlipRenderer.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
  gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  gl.glShadeModel(GL_SMOOTH);
  gl.glClearDepthf(1.0f);
  gl.glEnable(GL_DEPTH_TEST);
  gl.glDepthFunc(GL_LEQUAL);
  gl.glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

  created = true;

  cards.invalidateTexture();
  flipViewController.sendMessage(FlipViewController.MSG_SURFACE_CREATED);

  if (AphidLog.ENABLE_DEBUG) {
    AphidLog.d("onSurfaceCreated");
  }
}
 
Example 4
Source File: FlipRenderer.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
  gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  gl.glShadeModel(GL_SMOOTH);
  gl.glClearDepthf(1.0f);
  gl.glEnable(GL_DEPTH_TEST);
  gl.glDepthFunc(GL_LEQUAL);
  gl.glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

  created = true;

  cards.invalidateTexture();
  flipViewController.sendMessage(FlipViewController.MSG_SURFACE_CREATED);

  if (AphidLog.ENABLE_DEBUG) {
    AphidLog.d("onSurfaceCreated");
  }
}
 
Example 5
Source File: SolarSystemRenderer.java    From opengl with Apache License 2.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.glEnable(GL10.GL_CULL_FACE);
     gl.glCullFace(GL10.GL_BACK);
     gl.glShadeModel(GL10.GL_SMOOTH);
     gl.glEnable(GL10.GL_DEPTH_TEST);
}
 
Example 6
Source File: BouncyCubeRenderer.java    From opengl with Apache License 2.0 6 votes vote down vote up
public void onSurfaceCreated(GL10 gl, EGLConfig config) 
{

    gl.glDisable(GL11.GL_DITHER);

    gl.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT,
             GL11.GL_FASTEST);

    if (mTranslucentBackground) 
    {
         gl.glClearColor(1,0,0,0);
    } 
    else 
    {
         gl.glClearColor(1,1,1,1);
    }
    
    gl.glEnable(GL11.GL_CULL_FACE);
    gl.glShadeModel(GL11.GL_SMOOTH);
    gl.glEnable(GL11.GL_DEPTH_TEST);
}
 
Example 7
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 8
Source File: SolarSystemRenderer.java    From opengl with Apache License 2.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.glEnable(GL10.GL_CULL_FACE);
     gl.glCullFace(GL10.GL_BACK);
     gl.glShadeModel(GL10.GL_SMOOTH);
     gl.glEnable(GL10.GL_DEPTH_TEST);
}
 
Example 9
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 10
Source File: DemoHeartRateSensorActivity.java    From BLE-Heart-rate-variability-demo with MIT License 5 votes vote down vote up
public void onSurfaceCreated(GL10 gl, EGLConfig eglConfig) {
	gl.glDisable(GL10.GL_DITHER);
	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);
}
 
Example 11
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 12
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 13
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 14
Source File: OpenGLRenderer.java    From opengl with Apache License 2.0 5 votes vote down vote up
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
	// Set the background color to black ( rgba ).
	gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);  // OpenGL docs.
	// Enable Smooth Shading, default not really needed.
	gl.glShadeModel(GL10.GL_SMOOTH);// OpenGL docs.
	// Depth buffer setup.
	gl.glClearDepthf(1.0f);// OpenGL docs.
	// Enables depth testing.
	gl.glEnable(GL10.GL_DEPTH_TEST);// OpenGL docs.
	// The type of depth testing to do.
	gl.glDepthFunc(GL10.GL_LEQUAL);// OpenGL docs.
	// Really nice perspective calculations.
	gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, // OpenGL docs.
                         GL10.GL_NICEST);
}
 
Example 15
Source File: PageRenderer.java    From PlayLikeCurl with MIT License 5 votes vote down vote up
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
	frontPage.loadGLTexture(gl, this.context);
	rightPage.loadGLTexture(gl, this.context);
	leftPage.loadGLTexture(gl, this.context);


	gl.glEnable(GL10.GL_TEXTURE_2D);
	gl.glShadeModel(GL10.GL_SMOOTH);
	gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
	gl.glClearDepthf(1.0f);
	gl.glEnable(GL10.GL_DEPTH_TEST); 		
	gl.glDepthFunc(GL10.GL_LEQUAL); 	
	
	gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST); 
}
 
Example 16
Source File: CurlRenderer.java    From Android-Example with Apache License 2.0 5 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
	gl.glClearColor(0f, 0f, 0f, 1f);
	gl.glShadeModel(GL10.GL_SMOOTH);
	gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
	gl.glHint(GL10.GL_LINE_SMOOTH_HINT, GL10.GL_NICEST);
	gl.glHint(GL10.GL_POLYGON_SMOOTH_HINT, GL10.GL_NICEST);
	gl.glEnable(GL10.GL_LINE_SMOOTH);
	gl.glDisable(GL10.GL_DEPTH_TEST);
	gl.glDisable(GL10.GL_CULL_FACE);

	mObserver.onSurfaceCreated();
}
 
Example 17
Source File: MyGLRenderer.java    From TikTok with Apache License 2.0 5 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 gl,
                             javax.microedition.khronos.egl.EGLConfig arg1) {
    glBitmap.loadGLTexture(gl, this.context);

    gl.glEnable(GL10.GL_TEXTURE_2D); // Enable Texture Mapping ( NEW )
    gl.glShadeModel(GL10.GL_SMOOTH); // Enable Smooth Shading
    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
    gl.glClearDepthf(1.0f); // Depth Buffer Setup
    gl.glEnable(GL10.GL_DEPTH_TEST); // Enables Depth Testing
    gl.glDepthFunc(GL10.GL_LEQUAL); // The Type Of Depth Testing To Do

    gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
}
 
Example 18
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 19
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 20
Source File: SpriteTextRenderer.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();

    if (mLabels != null) {
        mLabels.shutdown(gl);
    } else {
        mLabels = new LabelMaker(true, 256, 64);
    }
    mLabels.initialize(gl);
    mLabels.beginAdding(gl);
    mLabelA = mLabels.add(gl, "A", mLabelPaint);
    mLabelB = mLabels.add(gl, "B", mLabelPaint);
    mLabelC = mLabels.add(gl, "C", mLabelPaint);
    mLabelMsPF = mLabels.add(gl, "ms/f", mLabelPaint);
    mLabels.endAdding(gl);

    if (mNumericSprite != null) {
        mNumericSprite.shutdown(gl);
    } else {
        mNumericSprite = new NumericSprite();
    }
    mNumericSprite.initialize(gl, mLabelPaint);
}