示例#1
0
    public GLState(GL11 gl) {
      mGL = gl;

      // Disable unused state
      gl.glDisable(GL11.GL_LIGHTING);

      // Enable used features
      gl.glEnable(GL11.GL_DITHER);

      gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
      gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
      gl.glEnable(GL11.GL_TEXTURE_2D);

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

      // Set the background color
      gl.glClearColor(0f, 0f, 0f, 0f);
      gl.glClearStencil(0);

      gl.glEnable(GL11.GL_BLEND);
      gl.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);

      // We use 565 or 8888 format, so set the alignment to 2 bytes/pixel.
      gl.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 2);
    }
示例#2
0
  // This is a GLSurfaceView.Renderer callback
  public void onSurfaceCreated(GL10 gl1, EGLConfig config) {
    GL11 gl = (GL11) gl1;
    if (mGL != null) {
      // The GL Object has changed
      Log.i(TAG, "GLObject has changed from " + mGL + " to " + gl);
    }
    mGL = gl;

    if (!ENABLE_FPS_TEST) {
      setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
    } else {
      setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
    }

    // Disable unused state
    gl.glDisable(GL11.GL_LIGHTING);

    // Enable used features
    gl.glEnable(GL11.GL_BLEND);
    gl.glEnable(GL11.GL_SCISSOR_TEST);
    gl.glEnable(GL11.GL_STENCIL_TEST);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glEnable(GL11.GL_TEXTURE_2D);
    mTexture2DEnabled = true;

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

    // Set the background color
    gl.glClearColor(0f, 0f, 0f, 0f);
    gl.glClearStencil(0);

    gl.glVertexPointer(2, GL11.GL_FLOAT, 0, mXyPointer);
    gl.glTexCoordPointer(2, GL11.GL_FLOAT, 0, mUvPointer);
  }