Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 21st, 2012  |  syntax: None  |  size: 1.26 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Adjusting contrast of a texture in OpenGL ES
  2. public void onDrawFrame(GL10 gl) {
  3.     if(cameraFrame == null) return;  
  4.  
  5.     gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
  6.     // modelview matrix
  7.     gl.glLoadIdentity();
  8.     // posunme TODO
  9.     gl.glTranslatef(0.0f, 0.0f, -5.0f);
  10.  
  11.     if(context.getResources().getBoolean(pda.lupa.R.bool.GL_view))
  12.         bindCameraTexture(gl);
  13.     else
  14.         gl.glColor4f(0f, 0f, 0.0f, 0f);
  15.  
  16.     gl.glNormal3f(0,0,1);
  17.     gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
  18.     gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
  19.  
  20.     gl.glFrontFace(GL10.GL_CW);
  21.  
  22.     gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
  23.     gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);
  24.  
  25.     gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);
  26.  
  27.     gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
  28.     gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
  29. }
  30.        
  31. gl.glGenTextures(1, cameraTexture, 0);
  32. int tex = cameraTexture[0];
  33. gl.glBindTexture(GL10.GL_TEXTURE_2D, tex);
  34. gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_LUMINANCE,
  35.     this.prevX, this.prevY, 0, GL10.GL_LUMINANCE,
  36.     GL10.GL_UNSIGNED_BYTE, ByteBuffer.wrap(this.cameraFrame));
  37.  
  38. gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);