Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - roytornado

Pages: [1]
1
I would like to display my camera preview to the screen and put 3d models on top of it.
I view all related post at this forum and still can't display it correctly. (only white color is blit to the buffer)

Background:
GL Version: 2.0
Screen size for GLSurfaceView: 1080X1080
Camera preview size: 736X736

Step:
Code: [Select]
onSurfaceChanged:
    TextureManager.getInstance().flush();
    mExternalTexture = new Texture(32, 32);
    mTextureRender.surfaceCreated();
    mSurfaceTexture = new SurfaceTexture(mTextureRender.getTextureId());
    mSurfaceTexture = new SurfaceTexture(mTextureRender.getTextureId());
    mSurfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() {
      @Override
      public void onFrameAvailable(SurfaceTexture surfaceTexture) {
        synchronized(CameraManager.this) {
          frameAvailable = true;
        }
      }
    });
    mExternalTexture.setExternalId(mTextureRender.getTextureId(), GLES11Ext.GL_TEXTURE_EXTERNAL_OES);
    TextureManager.getInstance().addTexture("camera_texture", mExternalTexture);
    mCamera = Camera.open();
    mCamera.setPreviewTexture(mSurfaceTexture);
    mCamera.startPreview();

Code: [Select]
onDrawFrame:
    frameBuffer.clear();
    synchronized(cameraManager) {
      if (cameraManager.frameAvailable) {
        frameBuffer.blit(cameraManager.mExternalTexture, 0, 0, 0, 0, 100, 100, false);
        mSurfaceTexture.updateTexImage();
      }
    }
    world.renderScene(frameBuffer);
    world.draw(frameBuffer);
    frameBuffer.display();

Any suggestion for me?



Pages: [1]