Camera, GLSurfaceView problem


  1. Netskilein

    Netskilein New Member

    Hello Everyone,

    actually i'm having a big problem while programming an augmented reality app where i need to overlap a cameraview and a glsurfaceview. Im trying to fix this for several days, but i cant get it solved. So here's my problem:
    I have an Activity "FView" where i currently Create 1 GLView (extends GLSurfaceView and implements a Renderer) and a CameraView (extends Surfaceview and implements SurfaceHolder.Callback..).
    I add both of the Views by the following code in the onCreate of the FView:
    [HIGH]
    glsurfaceview = new GLView(this);

    camPrev = new CamView(this, (PreviewCallback) glsurfaceview);
    glsurfaceview.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    glsurfaceview.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    glsurfaceview.setRenderer((GLView) glsurfaceview);
    setContentView(glsurfaceview);
    addContentView(camPrev, null);
    [/HIGH]This is the last "try". I already used a lot of other possibilities (e.g. different layouts..).
    What it does?
    When i start the Activity, holding my Smartphone in Landscape mode, i only see that the camera starts, no 3D-Objekts from my GLSurfaceView (the class itself works.. see following:).
    But when i hold my Smartphone in Portrait mode, it works fine!. But i need it to work in both ways - Start Activity while holding it in both ways, but the Activity itself must be in landscape all the time. Im freaking out because i dont know how to solve it !.

    I hope you can help me. Thanks.

    Advertisement
  2. jonbonazza

    jonbonazza Well-Known Member

    You should make a layout XML that consists of both Views and then set that layout file as the content view, using setContentView().

    Alternatively, you can subclass FrameLayout (or RelativeLayout) and construct both of your Views inside of its constructor, add the Views as children, and then instantiate the FrameLayout subclass and set it as the content view.

Share This Page