public void OnSurfaceChanged(IGL10 unused, int width, int height) { // Store width and height. _width = width; _height = height; // Calculate view aspect ratio. _aspectRatio[0] = (float)System.Math.Min(_width, _height) / _width; _aspectRatio[1] = (float)System.Math.Min(_width, _height) / _height; // Initialize textures. if (_fboExternal.Width != _width || _fboExternal.Height != _height) { _fboExternal.init(_width, _height, 1, true); } if (_fboOffscreen.Width != _width || _fboOffscreen.Height != _height) { _fboOffscreen.init(_width, _height, 1, false); } // Allocate new SurfaceTexture. SurfaceTexture oldSurfaceTexture = _surfaceTexture; _surfaceTexture = new SurfaceTexture(_fboExternal.GetTexture(0)); _surfaceTexture.SetOnFrameAvailableListener(this); // TODO: Ici vs OnFrameAvailable _surfaceTexture.FrameAvailable += _surfaceTexture_FrameAvailable; //???? Remove if (_observer != null) { _observer.OnSurfaceTextureCreated(_surfaceTexture); } if (oldSurfaceTexture != null) { oldSurfaceTexture.Dispose(); // Originally Release. Don't know the Xamarin translation of android java texture disposing. } RequestRender(); }
public void OnSurfaceCreated(Javax.Microedition.Khronos.Opengles.IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { // Set the background frame color GLES20.GlClearColor(0.0f, 0.0f, 0.0f, 1.0f); initTex(); mSTexture = new SurfaceTexture(hTex[0]); mSTexture.SetOnFrameAvailableListener(this); mCamera = Android.Hardware.Camera.Open(); try { mCamera.SetPreviewTexture(mSTexture); } catch (Exception ioe) { } GLES20.GlClearColor(0.0f, 0.0f, 0.0f, 1.0f); hProgram = loadShader(vss, fss); mTriangle = new Triangle(); }