views:

71

answers:

1

I am trying to merge two examples from the ApiDemos so one overlay over the other.
1. CameraPreview.java
2. TranslucentGLSurfaceViewActivity.java

I guess GLSurfaceView is not really necessary, I saw demos that uses a GL layer as a Camera PreviewCallback, but since I am such a noob at OpenGL, I am kind of lost. Can someone points me toward the light (figuratively speaking)?

+1  A: 

Instead of using the setContentView function only use the addContentView function. If you create both views in code you can just pass them as an argument. If a view is created in an xml file, create a View object by inflating the xml with:

 View.inflate(this, R.layout.XMLname, null);

Then you can just add both views and you are done. The trick here is however to add them in the right order. If I recall correctly, even though the logical order might be to first add the camera preview and then the GL surfacview, you need to do it the other way around. In case I am mistaking here, it should be easy to find out the correct order with your two possible options.

Pandoro
addContentView is not enough to do the trick, cause both camera and opengl are constantly changing frames, and I only see one or the other. I am looking if there is an alternative to feeding the camera image to the GLLayer to produce the final product.
I'm sorry to say, but you must be doing something else wrong then. Currently I am using the exact same thing as I described. Additional to that I have another layer of buttons and texviews. My exact order is the following: 1) openglView 2) Camera preview 3) additional view. This works just fine for me. A buddy of mine uses the same setup in a different app. I would avoid feeding the camera into the GLLayer, even though it is just a hunch, I think this will have bad effects.
Pandoro