안녕하세요

 OpenGL을 사용해서

 동영상을 재생하는 어플리케이션을 만들고 있습니다.


 화면에 사각형을 만들고

 영상을 Texture로 입힌 다음, Texture를 계속해서 갱신하는 방법으로 구현했습니다.

 
 그 결과, 영상이 10-20여초정도 잘 재생되다가

 어느 순간  영상이 멈칫멈칫하면서 재대로 재생되지 않습니다.



 LogCat으로 찍어보니 다음과 같은 로그가 나타났습니다. 

 Adreno200-EGL  eglLockWindowSurface: failed to map the memory for fd=27 offs=1536000
 Adreno200-EGL  eglLockWindowSurface: failed to map the memory for fd=27 offs=1536000
 Adreno200-EGL  eglLockWindowSurface: failed to map the memory for fd=26 offs=0
 Adreno200-EGL  eglLockWindowSurface: failed to map the memory for fd=26 offs=0
 Adreno200-EGL  eglLockWindowSurface: failed to map the memory for fd=41 offs=8032256
 Adreno200-EGL  eglLockWindowSurface: failed to map the memory for fd=27 offs=1536000
                                                                ....
                                                                ...
             

 로그로 판단하기에는, Surface에 뿌려주는 Buffer같은 것이 있는거 같은데, 그것이 제대로 비워지지 않는것 같습니다..

 OpenGL에 정통한 분들께 도움을 요청합니다..ㅜ

 


 제가 구현한 Rederer는 다음과 같습니다.

  public void onSurfaceCreated(GL10 gl, EGLConfig config) {  
  gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
 }

 /**
  * Here we do our drawing
  */
 public void onDrawFrame(GL10 gl) {
  cube.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

  
  //Clear Screen And Depth Buffer
  gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); 
  gl.glLoadIdentity();     //Reset The Current Modelview Matrix
  
  //Drawing
  gl.glTranslatef(0.0f, 0.0f, -4.0f);  //Move 5 units into the screen
  cube.draw(gl);       //Draw the Cube 
 }


위의 cube.loadGLTexture(gl,this.context); 는 다음과 같이 구현되어 있습니다.

 public void loadGLTexture(GL10 gl, Context context) {
  Bitmap bitmap = Bitmap.createBitmap(320,240,Bitmap.Config.ARGB_8888);
  bitmap.setPixels( VIDEO_DATA,0,320,0,0,320,240);

  gl.glGenTextures(1, textures, 0);
 gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
  
  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);

 GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
  
  bitmap.recycle();
 }


cube.draw(gl)은 다음과 같이 구성되어 있습니다.

 public void draw(GL10 gl) {
  //Bind our only previously generated texture in this case
  gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
  
  //Point to our buffers
  gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
  gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

  //Set the face rotation
  gl.glFrontFace(GL10.GL_CCW);
  
  //Enable the vertex and texture state
  gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
  gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);
  
  //Draw the vertices as triangles, based on the Index Buffer information
  gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_BYTE, indexBuffer);
  
  //Disable the client state before leaving
  gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
  gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
 }