Posts

Showing posts with the label OpenGL

How to draw an overlay on a SurfaceView used by Camera on Android?

Solution 1: I have a simple program that draws the preview of the Camera into a SurfaceView . What I'm trying to do is using the onPreviewFrame method, which is invoked each time a new frame is drawn into the SurfaceView , in order to execute the invalidate method which is supposed to invoke the onDraw method. In fact, the onDraw method is being invoked, but nothing there is being printed (I guess the camera preview is overwriting the text I'm trying to draw). This is a simplify version of the SurfaceView subclass I have: public class Superficie extends SurfaceView implements SurfaceHolder . Callback { SurfaceHolder mHolder ; public Camera camera ; Superficie ( Context context ) { super ( context ); mHolder = getHolder (); mHolder . addCallback ( this ); mHolder . setType ( SurfaceHolder . SURFACE_TYPE_PUSH_BUFFERS ); } public void surfaceCreated ( final SurfaceHolder holder ) { camera = Camera . open (); try { ...

Create a spinning cube with OpenGL ES and Android

Image
Android supports 3D graphics via the OpenGL ES API, a flavor of OpenGL specifically designed for embedded devices. This article is not an OpenGL tutorial, it assumes the reader has already basic OpenGL knowledge. The final result will look like this: First we write a new Activity and in the onCreate method we create the two fundamental objects we need to use the OpenGL API: a GLSurfaceView and a Renderer . public class OpenGLDemoActivity extends Activity { @Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ); // Go fullscreen requestWindowFeature ( Window . FEATURE_NO_TITLE ); getWindow (). setFlags ( WindowManager . LayoutParams . FLAG_FULLSCREEN , WindowManager . LayoutParams . FLAG_FULLSCREEN ); GLSurfaceView view = new GLSurfaceView ( this ); view . setRenderer ( new OpenGLRenderer ()); ...

how to make surfaceview transparent

Try this: SurfaceView sfvTrack = ( SurfaceView ) findViewById ( R . id . sfvTrack ); sfvTrack . setZOrderOnTop ( true ); // necessary sfhTrack = sfvTrack . getHolder (); sfhTrack . setFormat ( PixelFormat . TRANSPARENT );