[android-beginners] Re: OpenGL View on top of Camera
Thank you Julius, Unfortunately, I cannot it get it work as I use the emulator (SDK 1.5 r1) (and do not have any device) The emulator does not handle the transparency format (http:// groups.google.com/group/android-developers/browse_thread/thread/ 7d18f1b3480ff242) I only get a blank screen with a small part of the screen below showing the camera preview. Did anyone try on older version of the emulator ? If it works fine on devices, I can still work on it disabling temporary the line: mGLSurfaceView.getHolder().setFormat (PixelFormat.TRANSLUCENT); And enabling it when I plan to distribute it on devices... On Jun 12, 7:15 am, julius wrote: > Hi, > > Sorry I didn't see the replies til now. The Preview code I grabbed > from somewhere in the forum. It may not be the correct way to do it, > but it seems to work. Anyone know much about how to use quarternions > in Java? > > I did it a bit back to front: > > Find TranslucentGLSurfaceViewActivity in the Demos, > > Then add (in onCreate): > > mPreview = new Preview(this); > addContentView(mPreview, new LayoutParams(LayoutParams.WRAP_CONTENT, > LayoutParams.WRAP_CONTENT)); > > and add the member variable: > private Preview mPreview; > > class Preview extends SurfaceView implements SurfaceHolder.Callback { > SurfaceHolder mHolder; > CameramCamera; > > Preview(Context context) { > super(context); > > // Install a SurfaceHolder.Callback so we get notified when the > // underlying surface is created and destroyed. > mHolder = getHolder(); > mHolder.addCallback(this); > mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); > } > > public void surfaceCreated(SurfaceHolder holder) { > // The Surface has been created, acquire thecameraand tell it > where > // to draw. > mCamera =Camera.open(); > mCamera.setPreviewDisplay(holder); > } > > public void surfaceDestroyed(SurfaceHolder holder) { > // Surface will be destroyed when we return, so stop the > preview. > // Because the CameraDevice object is not a shared resource, > it's very > // important to release it when the activity is paused. > mCamera.stopPreview(); > mCamera = null; > } > > public void surfaceChanged(SurfaceHolder holder, int format, int w, > int h) { > // Now that the size is known, set up thecameraparameters and > begin > // the preview. > Camera.Parameters parameters = mCamera.getParameters(); > parameters.setPreviewSize(w, h); > mCamera.setParameters(parameters); > mCamera.startPreview(); > } > > } > > Regards, > Julius. > > http://www.juliusspencer.co.nz --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~--~~~~--~~--~--~---
[android-beginners] Re: OpenGL View on top of Camera
Hi, Sorry I didn't see the replies til now. The Preview code I grabbed from somewhere in the forum. It may not be the correct way to do it, but it seems to work. Anyone know much about how to use quarternions in Java? I did it a bit back to front: Find TranslucentGLSurfaceViewActivity in the Demos, Then add (in onCreate): mPreview = new Preview(this); addContentView(mPreview, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); and add the member variable: private Preview mPreview; class Preview extends SurfaceView implements SurfaceHolder.Callback { SurfaceHolder mHolder; Camera mCamera; Preview(Context context) { super(context); // Install a SurfaceHolder.Callback so we get notified when the // underlying surface is created and destroyed. mHolder = getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } public void surfaceCreated(SurfaceHolder holder) { // The Surface has been created, acquire the camera and tell it where // to draw. mCamera = Camera.open(); mCamera.setPreviewDisplay(holder); } public void surfaceDestroyed(SurfaceHolder holder) { // Surface will be destroyed when we return, so stop the preview. // Because the CameraDevice object is not a shared resource, it's very // important to release it when the activity is paused. mCamera.stopPreview(); mCamera = null; } public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { // Now that the size is known, set up the camera parameters and begin // the preview. Camera.Parameters parameters = mCamera.getParameters(); parameters.setPreviewSize(w, h); mCamera.setParameters(parameters); mCamera.startPreview(); } } Regards, Julius. http://www.juliusspencer.co.nz --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~--~~~~--~~--~--~---
[android-beginners] Re: OpenGL View on top of Camera
Yeah, it would be nice to tell people how you did it. On May 3, 12:30 am, "Carl H." wrote: > Hello Julius, > > did you manage to make it work? The following post doubts the > possibility of enabling 2 > SurfaceViews:http://groups.google.com/group/android-developers/browse_thread/threa... > > Could you post your code by any chance. > > Cheers, > Carl > > On Apr 27, 3:41 am, Julius Spencer wrote: > > > Hi, > > > Apologies - no sooner than I send it and I get it going. :) > > > Julius. > > > On 27/04/2009, at 1:32 PM, Julius Spencer wrote: > > > > Hi, > > > > I am trying to add an OpenGL View on top of a camera preview View but > > > I'm getting unexpected results (I can't see the OpenGL object). > > > > I'm probably missing (not understanding) something obvious. :) > > > > Either View works on its own and I can add a simple Canvas to the > > > preview just not the OpenGL View. > > > > super.onCreate(savedInstanceState); > > > > // Hide the window title. > > > requestWindowFeature(Window.FEATURE_NO_TITLE); > > > > // Create our Preview view and set it as the content of our activity. > > > mPreview = new Preview(this); > > > mGLView = new GLSurfaceView(this); > > > mGLView.setRenderer(new CubeRenderer(true)); > > > > setContentView(mPreview); > > > > addContentView(mGLView, new LayoutParams(LayoutParams.WRAP_CONTENT, > > > LayoutParams.WRAP_CONTENT)); > > > > Thanks for any help / education. > > > > Cheers, > > > Julius. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~--~~~~--~~--~--~---
[android-beginners] Re: OpenGL View on top of Camera
Hello Julius, did you manage to make it work? The following post doubts the possibility of enabling 2 SurfaceViews: http://groups.google.com/group/android-developers/browse_thread/thread/4850fe5c314a3dc6 Could you post your code by any chance. Cheers, Carl On Apr 27, 3:41 am, Julius Spencer wrote: > Hi, > > Apologies - no sooner than I send it and I get it going. :) > > Julius. > > On 27/04/2009, at 1:32 PM, Julius Spencer wrote: > > > > > Hi, > > > I am trying to add an OpenGL View on top of a camera preview View but > > I'm getting unexpected results (I can't see the OpenGL object). > > > I'm probably missing (not understanding) something obvious. :) > > > Either View works on its own and I can add a simple Canvas to the > > preview just not the OpenGL View. > > > super.onCreate(savedInstanceState); > > > // Hide the window title. > > requestWindowFeature(Window.FEATURE_NO_TITLE); > > > // Create our Preview view and set it as the content of our activity. > > mPreview = new Preview(this); > > mGLView = new GLSurfaceView(this); > > mGLView.setRenderer(new CubeRenderer(true)); > > > setContentView(mPreview); > > > addContentView(mGLView, new LayoutParams(LayoutParams.WRAP_CONTENT, > > LayoutParams.WRAP_CONTENT)); > > > Thanks for any help / education. > > > Cheers, > > Julius. > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~--~~~~--~~--~--~---
[android-beginners] Re: OpenGL View on top of Camera
Hi, Apologies - no sooner than I send it and I get it going. :) Julius. On 27/04/2009, at 1:32 PM, Julius Spencer wrote: > > Hi, > > I am trying to add an OpenGL View on top of a camera preview View but > I'm getting unexpected results (I can't see the OpenGL object). > > I'm probably missing (not understanding) something obvious. :) > > Either View works on its own and I can add a simple Canvas to the > preview just not the OpenGL View. > > > super.onCreate(savedInstanceState); > > // Hide the window title. > requestWindowFeature(Window.FEATURE_NO_TITLE); > > // Create our Preview view and set it as the content of our activity. > mPreview = new Preview(this); > mGLView = new GLSurfaceView(this); > mGLView.setRenderer(new CubeRenderer(true)); > > > setContentView(mPreview); > > addContentView(mGLView, new LayoutParams(LayoutParams.WRAP_CONTENT, > LayoutParams.WRAP_CONTENT)); > > > > Thanks for any help / education. > > Cheers, > Julius. > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~--~~~~--~~--~--~---