void IGLKViewDelegate.DrawInRect(GLKView view, CoreGraphics.CGRect rect) { if (m_Ftime.Count == FpsFrames) { m_Ftime.RemoveAt(0); } m_Ftime.Add(m_Stopwatch.ElapsedMilliseconds - m_LastTime); m_LastTime = m_Stopwatch.ElapsedMilliseconds; if (m_Stopwatch.ElapsedMilliseconds > 1000) { m_UnitTest.Note = String.Format("String Cache size: {0} Draw Calls: {1} Vertex Count: {2}", m_Renderer.TextCacheSize, m_Renderer.DrawCallCount, m_Renderer.VertexCount); m_UnitTest.Fps = 1000f * m_Ftime.Count / m_Ftime.Sum(); m_Stopwatch.Restart(); if (m_Renderer.TextCacheSize > 1000) // each cached string is an allocated texture, flush the cache once in a while in your real project { m_Renderer.FlushTextCache(); } } GL.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit); m_Canvas.RenderCanvas(); }
public override void DrawInRect(GLKView view, CGRect rect) { //var onDisplay = _model.OnDisplay; //if (onDisplay == null) // return; //onDisplay(rect.ToRectangle()); }
public override void ViewDidLoad() { base.ViewDidLoad(); context = new EAGLContext(EAGLRenderingAPI.OpenGLES3); if (context == null) { context = new EAGLContext(EAGLRenderingAPI.OpenGLES2); if (context == null) { throw new Exception("Unable to create OpenGL ES2 Context"); } Window.SetObsoleteMode(); } view = (GLKView)View; view.Context = context; view.DrawableDepthFormat = GLKViewDrawableDepthFormat.Format24; EAGLContext.SetCurrentContext(context); window = new Window(view); GameSetup(window); }
public void glkViewDrawInRect(GLKView view, RectangleF rect) { if (_vertexBuffers == null) return; GL.ClearColor (0.0f, 0.0f, 0.0f, 1.0f); // Clear all old bits GL.Clear ((int)(All.ColorBufferBit)); _effect.Transform.ModelViewMatrix = _modelMatrix; _effect.Material.AmbientColor = new Vector4 (.3f, 0f, 0f, 1f); _effect.Material.DiffuseColor = new Vector4 (.8f, 0f, 0f, 1f); _effect.Light0.AmbientColor = new Vector4 (.6f, .6f, .6f, 1f); _effect.PrepareToDraw (); GL.BindBuffer(All.ArrayBuffer, _vertexBuffers[0]); GL.EnableVertexAttribArray((uint)GLKVertexAttrib.Position); GL.VertexAttribPointer((uint)GLKVertexAttrib.Position, 3, All.Float, false, 0, IntPtr.Zero); GL.BindBuffer(All.ArrayBuffer, _vertexBuffers[1]); GL.EnableVertexAttribArray((uint)GLKVertexAttrib.Normal); GL.VertexAttribPointer((uint)GLKVertexAttrib.Normal, 3, All.Float, false, 0, IntPtr.Zero); GL.DrawArrays(All.Triangles, 0, _triangles); GL.Flush (); }
public new void DrawInRect(GLKView view, CGRect rect) { if (designMode) { return; } if (context == null) { var glInterface = GRGlInterface.CreateNativeGlInterface(); context = GRContext.Create(GRBackend.OpenGL, glInterface); // get the initial details renderTarget = SKGLDrawable.CreateRenderTarget(); } // set the dimensions as they might have changed renderTarget.Width = (int)DrawableWidth; renderTarget.Height = (int)DrawableHeight; // create the surface using (var surface = SKSurface.Create(context, renderTarget)) { // draw on the surface DrawInSurface(surface, renderTarget); surface.Canvas.Flush(); } // flush the SkiaSharp contents to GL context.Flush(); }
public override void DrawInRect(GLKView view, CGRect rect) { GL.Clear(ClearBufferMask.ColorBufferBit); if (ripple != null) { GL.DrawElements(BeginMode.TriangleStrip, ripple.IndexCount, DrawElementsType.UnsignedShort, IntPtr.Zero); } }
public void InitWithFrame() { var frame = new CGRect(10, 10, 100, 100); using (GLKView glkv = new GLKView(frame)) { Assert.That(glkv.Frame, Is.EqualTo(frame), "Frame"); } }
// Render image to display. public void DrawInRect(GLKView view, CGRect rect) { var context = ciContext; if (context == null) { return; } var filter = ciRawFilter; if (filter == null) { return; } var nativeSize = imageNativeSize; if (!nativeSize.HasValue) { return; } // OpenGLES drawing setup. ClearColor(0, 0, 0, 1); Clear(ClearBufferMask.ColorBufferBit); // Set the blend mode to "source over" so that CI will use that. Enable(EnableCap.Blend); BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha); // Calculate scale to show the image at. var scaleTransform = MakeScale(view.ContentScaleFactor, view.ContentScaleFactor); var contentScaledRect = CGRectApplyAffineTransform(rect, scaleTransform); var scale = (float)Math.Min(contentScaledRect.Width / nativeSize.Value.Width, contentScaledRect.Height / nativeSize.Value.Height); // Set scale factor of the CIRawFilter to size it correctly for display. filter.SetValueForKey(NSNumber.FromFloat(scale), Keys.kCIInputScaleFactorKey); // Calculate rectangle to display image in. var displayRect = CGRectApplyAffineTransform(new CGRect(0, 0, nativeSize.Value.Width, nativeSize.Value.Height), MakeScale(scale, scale)); // Ensure the image is centered. displayRect.X = (contentScaledRect.Width - displayRect.Width) / 2; displayRect.Y = (contentScaledRect.Height - displayRect.Height) / 2; var image = ciRawFilter.OutputImage; if (image == null) { return; } // Display the image scaled to fit. context.DrawImage(image, displayRect, image.Extent); }
public override void DrawInRect(GLKView view, RectangleF rect) { var onDisplay = _model.OnDisplay; if (onDisplay == null) { return; } onDisplay(rect.ToRectangle()); }
public override void DrawInRect(GLKView view, CGRect rect) { Action <Rectangle> onDisplay = this.model.get_OnDisplay(); if (onDisplay == null) { return; } onDisplay(RectangleExtensions.ToRectangle(rect)); }
public void DrawInRect(GLKView view, CGRect rect) { GL.ClearColor(0.65f, 0.65f, 0.65f, 1f); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.Oes.BindVertexArray(vertexArray); effect.PrepareToDraw(); GL.DrawArrays(BeginMode.Triangles, 0, Monkey.MeshVertexData.Length / 6); }
public Window(GLKView view) { context = view; // on mobile refresh is capped to 60hz this._deltaTime = 1f / 60f; FixMobileViewport(); FinalizeSetup(); }
public override void OnRedrawRequested() { GLKView view = null; if (_viewRef.TryGetTarget(out view)) { if (view != null) // check probably not needed { DispatchQueue.MainQueue.DispatchAsync( new System.Action(view.SetNeedsDisplay) ); } } }
public new void DrawInRect(GLKView view, CGRect rect) { if (designMode) { return; } // create the contexts if not done already if (context == null) { var glInterface = GRGlInterface.CreateNativeGlInterface(); context = GRContext.Create(GRBackend.OpenGL, glInterface); } // manage the drawing surface if (renderTarget == null || surface == null || renderTarget.Width != DrawableWidth || renderTarget.Height != DrawableHeight) { // create or update the dimensions renderTarget?.Dispose(); Gles.glGetIntegerv(Gles.GL_FRAMEBUFFER_BINDING, out var framebuffer); Gles.glGetIntegerv(Gles.GL_STENCIL_BITS, out var stencil); Gles.glGetIntegerv(Gles.GL_SAMPLES, out var samples); var maxSamples = context.GetMaxSurfaceSampleCount(colorType); if (samples > maxSamples) { samples = maxSamples; } var glInfo = new GRGlFramebufferInfo((uint)framebuffer, colorType.ToGlSizedFormat()); renderTarget = new GRBackendRenderTarget((int)DrawableWidth, (int)DrawableHeight, samples, stencil, glInfo); // create the surface surface?.Dispose(); surface = SKSurface.Create(context, renderTarget, surfaceOrigin, colorType); } using (new SKAutoCanvasRestore(surface.Canvas, true)) { // start drawing var e = new SKPaintGLSurfaceEventArgs(surface, renderTarget, surfaceOrigin, colorType); OnPaintSurface(e); #pragma warning disable CS0618 // Type or member is obsolete DrawInSurface(e.Surface, e.RenderTarget); #pragma warning restore CS0618 // Type or member is obsolete } // flush the SkiaSharp contents to GL surface.Canvas.Flush(); context.Flush(); }
void IGLKViewDelegate.DrawInRect(GLKView view, CoreGraphics.CGRect rect) { GL.ClearColor(0.65f, 0.65f, 0.65f, 1.0f); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.Oes.BindVertexArray(m_vaoObject); //GL.DrawArrays (BeginMode.Triangles, 0, 36); // Render the object again with ES2 GL.UseProgram(m_shaderProgram); GL.DrawArrays(BeginMode.Triangles, 0, 9); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. _eaglContext = new EAGLContext(EAGLRenderingAPI.OpenGLES2); _captureSession = new AVCaptureSession(); _imageView = new GLKView(); _cIContext = CIContext.FromContext(_eaglContext); InitialiseCaptureSession(); View.AddSubview(_imageView); _imageView.Context = _eaglContext; _imageView.Delegate = this; }
private void SetNeedsDisplay() { try { GLKView view = null; lock (this) { _viewRef.TryGetTarget(out view); } if (view != null) { view.SetNeedsDisplay(); } } catch (System.Exception e) { Carto.Utils.Log.Error("MapRedrawRequestListener.SetNeedsDisplay: " + e); } }
public override void DrawInRect(GLKView view, CoreGraphics.CGRect rect) { if (!isActive()) { return; } UIInterfaceOrientation orientation = UIApplication.SharedApplication.StatusBarOrientation; CGSize size; GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); if (firstGLUpdate == false) { ApplyCameraGlOrientation(orientation); firstGLUpdate = true; } if (orientation == UIInterfaceOrientation.Portrait || orientation == UIInterfaceOrientation.PortraitUpsideDown) { size = new CGSize(ViewportHeight, ViewportWidth); } else { size = new CGSize(ViewportWidth, ViewportHeight); } RenderCamera(size, Angle); if (isTracking()) { if (CurrentMarker != null) { if (CurrentMarker.Id == "3_543") { float[] mvpMatrix = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; if (computeModelViewProjectionMatrix(ref mvpMatrix)) { mMonkeyMesh.DrawMesh(ref mvpMatrix); RenderUtils.CheckGLError(); } } } } GL.Finish(); }
public void OnSurfaceCreated(GLKView glkView) { m_GLGraphics = new GLGraphics(glkView); Debug.WriteLine(string.Format("Width:{0} / Height:{1}", m_GLGraphics.GetWidth(), m_GLGraphics.GetHeight())); m_Input = new IOSInput(); lock (m_StateChanged) { if (m_State == GLGameState.Initialized) { m_Screen = GetStartScreen(); } m_State = GLGameState.Running; m_Screen.Resume(); } }
public override void ViewDidLoad () { bool isPad = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad; base.ViewDidLoad (); context = new EAGLContext (EAGLRenderingAPI.OpenGLES2); glkView = (GLKView) View; glkView.Context = context; glkView.MultipleTouchEnabled = true; PreferredFramesPerSecond = 60; size = UIScreen.MainScreen.Bounds.Size.ToRoundedCGSize (); View.ContentScaleFactor = UIScreen.MainScreen.Scale; meshFactor = isPad ? 8 : 4; SetupGL (); SetupAVCapture (isPad ? AVCaptureSession.PresetiFrame1280x720 : AVCaptureSession.Preset640x480); }
public override void ViewDidLoad() { base.ViewDidLoad(); context = new EAGLContext(EAGLRenderingAPI.OpenGLES2); if (context == null) { Console.WriteLine("Failed to create ES context"); } GLKView view = View as GLKView; view.Context = context; view.DrawableDepthFormat = GLKViewDrawableDepthFormat.Format24; setupGL(); }
public override void ViewDidLoad() { bool isPad = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad; base.ViewDidLoad(); context = new EAGLContext(EAGLRenderingAPI.OpenGLES2); glkView = (GLKView)View; glkView.Context = context; glkView.MultipleTouchEnabled = true; PreferredFramesPerSecond = 60; size = UIScreen.MainScreen.Bounds.Size.ToRoundedCGSize(); View.ContentScaleFactor = UIScreen.MainScreen.Scale; meshFactor = isPad ? 8 : 4; SetupGL(); SetupAVCapture(isPad ? AVCaptureSession.PresetiFrame1280x720 : AVCaptureSession.Preset640x480); }
public new void DrawInRect(GLKView view, CGRect rect) { #if false if (designMode) { return; } #endif // create the contexts if not done already if (_context == null) { var glInterface = GRGlInterface.CreateNativeGlInterface(); _context = GRContext.Create(GRBackend.OpenGL, glInterface); } // manage the drawing surface if (_renderTarget == null || _surface == null || _renderTarget.Width != DrawableWidth || _renderTarget.Height != DrawableHeight) { // create or update the dimensions _renderTarget?.Dispose(); Gles.glGetIntegerv(Gles.GL_FRAMEBUFFER_BINDING, out int framebuffer); Gles.glGetIntegerv(Gles.GL_STENCIL_BITS, out int stencil); var glInfo = new GRGlFramebufferInfo((uint)framebuffer, colorType.ToGlSizedFormat()); _renderTarget = new GRBackendRenderTarget((int)DrawableWidth, (int)DrawableHeight, _context.GetMaxSurfaceSampleCount(colorType), stencil, glInfo); // create the surface _surface?.Dispose(); _surface = SKSurface.Create(_context, _renderTarget, surfaceOrigin, colorType); } using (new SKAutoCanvasRestore(_surface.Canvas, true)) { // start drawing //var e = new SKPaintGLSurfaceEventArgs(surface, renderTarget, surfaceOrigin, colorType); PaintSurface(_surface); } // flush the SkiaSharp contents to GL _surface.Canvas.Flush(); _context.Flush(); }
public override void DrawInRect(GLKView view, CGRect rect) { if (!isDeviceMotionAvailable) { return; } GL.ClearColor(0.0f, 0.0f, 0.0f, 1.0f); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.Oes.BindVertexArray(vertexArray); // Render the objects with GLKit for (int i = 0; i < (NumCubes + NumStars); i++) { var effect = effects [i]; effect.PrepareToDraw(); GL.DrawArrays(BeginMode.Triangles, 0, 36); } }
void IGLKViewDelegate.DrawInRect(GLKView view, CoreGraphics.CGRect rect) { GL.ClearColor(0.65f, 0.65f, 0.65f, 1.0f); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.Oes.BindVertexArray(vertexArray); // Render the object with GLKit effect.PrepareToDraw(); GL.DrawArrays(BeginMode.Triangles, 0, 36); // Render the object again with ES2 GL.UseProgram(program); GL.UniformMatrix4(uniforms[(int)Uniform.ModelViewProjection_Matrix], false, ref modelViewProjectionMatrix); GL.UniformMatrix3(uniforms[(int)Uniform.Normal_Matrix], false, ref normalMatrix); GL.DrawArrays(BeginMode.Triangles, 0, 36); }
public new void DrawInRect(GLKView view, CGRect rect) { if (designMode) { return; } // create the contexts if not done already if (context == null) { var glInterface = GRGlInterface.CreateNativeGlInterface(); context = GRContext.Create(GRBackend.OpenGL, glInterface); } // manage the drawing surface if (renderTarget == null || surface == null || renderTarget.Width != DrawableWidth || renderTarget.Height != DrawableHeight) { // create or update the dimensions renderTarget?.Dispose(); renderTarget = SKGLDrawable.CreateRenderTarget((int)DrawableWidth, (int)DrawableHeight); // create the surface surface?.Dispose(); surface = SKSurface.Create(context, renderTarget, GRSurfaceOrigin.BottomLeft, SKColorType.Rgba8888); } using (new SKAutoCanvasRestore(surface.Canvas, true)) { // start drawing var e = new SKPaintGLSurfaceEventArgs(surface, renderTarget, GRSurfaceOrigin.BottomLeft, SKColorType.Rgba8888); OnPaintSurface(e); #pragma warning disable CS0618 // Type or member is obsolete DrawInSurface(e.Surface, e.RenderTarget); #pragma warning restore CS0618 // Type or member is obsolete } // flush the SkiaSharp contents to GL surface.Canvas.Flush(); context.Flush(); }
public GLGraphics(GLKView glView) { this.m_GlView = glView; if (Setting.CanUseSafeArea) { //var margins = glView.LayoutMargins; var margins = glView.SafeAreaInsets; m_DrawableAreaRect = new CGRect( margins.Left, margins.Top, (GetWidth() - (margins.Left + margins.Right)), (GetHeight() - (margins.Top + margins.Bottom))); m_ScaleFactor = (float)glView.ContentScaleFactor; } else { m_DrawableAreaRect = new CGRect(0, 0, GetDrawableWidth(), GetDrawableHeight()); m_ScaleFactor = 1.0f; } }
void IGLKViewDelegate.DrawInRect(GLKView view, CoreGraphics.CGRect rect) { #if _SAMPLE GL.ClearColor(0.65f, 0.65f, 0.65f, 1.0f); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.Oes.BindVertexArray(vertexArray); // Render the object with GLKit effect.PrepareToDraw(); GL.DrawArrays(BeginMode.Triangles, 0, 36); // Render the object again with ES2 GL.UseProgram(program); GL.UniformMatrix4(uniforms [(int)Uniform.ModelViewProjection_Matrix], false, ref modelViewProjectionMatrix); GL.UniformMatrix3(uniforms [(int)Uniform.Normal_Matrix], false, ref normalMatrix); GL.DrawArrays(BeginMode.Triangles, 0, 36); #endif #if _ENGINE if (!Initialized) { Initialized = true; int [] viewport = new int[4]; GL.GetInteger(GetPName.Viewport, viewport); //CGSize size = View.Bounds.Size; //int DeviceWidth = (int) UIScreen.MainScreen.Bounds.Width ; //int DeviceHeight = (int) UIScreen.MainScreen.Bounds.Height; Utility = new XMUtilities(); XamarinInit(viewport[2], viewport[3], (int)rect.Width, (int)rect.Height); } XamarinRender(); #endif }
public override void DrawInRect(GLKView view, CGRect rect) { ((MapView)view).OnDraw(); }
// Render image to display. public void DrawInRect (GLKView view, CGRect rect) { var context = ciContext; if (context == null) return; var filter = ciRawFilter; if (filter == null) return; var nativeSize = imageNativeSize; if (!nativeSize.HasValue) return; // OpenGLES drawing setup. ClearColor (0, 0, 0, 1); Clear (ClearBufferMask.ColorBufferBit); // Set the blend mode to "source over" so that CI will use that. Enable (EnableCap.Blend); BlendFunc (BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha); // Calculate scale to show the image at. var scaleTransform = MakeScale (view.ContentScaleFactor, view.ContentScaleFactor); var contentScaledRect = CGRectApplyAffineTransform (rect, scaleTransform); var scale = (float)Math.Min (contentScaledRect.Width / nativeSize.Value.Width, contentScaledRect.Height / nativeSize.Value.Height); // Set scale factor of the CIRawFilter to size it correctly for display. filter.SetValueForKey (NSNumber.FromFloat (scale), Keys.kCIInputScaleFactorKey); // Calculate rectangle to display image in. var displayRect = CGRectApplyAffineTransform (new CGRect (0, 0, nativeSize.Value.Width, nativeSize.Value.Height), MakeScale (scale, scale)); // Ensure the image is centered. displayRect.X = (contentScaledRect.Width - displayRect.Width) / 2; displayRect.Y = (contentScaledRect.Height - displayRect.Height) / 2; var image = ciRawFilter.OutputImage; if (image == null) return; // Display the image scaled to fit. context.DrawImage (image, displayRect, image.Extent); }
void _setupGLView() { // Craete a new context if needed if (EAGLContext.CurrentContext == null) EAGLContext.SetCurrentContext (new EAGLContext (EAGLRenderingAPI.OpenGLES2)); _view = new GLKView (this.View.Bounds); _view.Context = EAGLContext.CurrentContext; _view.WeakDelegate = this; this.View.AddSubview (_view); _effect = new GLKBaseEffect (); _effect.Light0.Position = new Vector4 (5, 5, 5, 1); _effect.Light0.Enabled = true; GL.Enable (All.CullFace); sizeGLView (); _modelMatrix = Matrix4.CreateRotationX ((float)Math.PI / 5f); _effect.Transform.ModelViewMatrix = _modelMatrix; createBuffers (1); }
public void DrawInRect (GLKView view, CGRect rect) { GL.ClearColor (0.65f, 0.65f, 0.65f, 1f); GL.Clear (ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.Oes.BindVertexArray (vertexArray); effect.PrepareToDraw (); GL.DrawArrays (BeginMode.Triangles, 0, Monkey.MeshVertexData.Length / 6); }
public override void DrawInRect(GLKView view, RectangleF rect) { Console.WriteLine(rect); GL.ClearColor(Color.Maroon); GL.Clear(ClearBufferMask.ColorBufferBit); }
public void DrawInRect(GLKView view, CGRect rect) { _cIContext.DrawImage( _cameraImage, new CGRect(0, 0, _imageView.DrawableWidth, _imageView.DrawableHeight), _cameraImage.Extent); }
public MapRedrawRequestListener(GLKView view) { _viewRef = new WeakReference <GLKView>(view); }
public override void DrawInRect (GLKView view, CGRect rect) { GL.Clear (ClearBufferMask.ColorBufferBit); if (ripple != null) GL.DrawElements (BeginMode.TriangleStrip, ripple.IndexCount, DrawElementsType.UnsignedShort, IntPtr.Zero); }
public override void DrawInRect(GLKView view, CoreGraphics.CGRect rect) { m_Activity.OnDrawFrame(); }
public override void DrawInRect (GLKView view, CGRect rect) { if (!isDeviceMotionAvailable) return; GL.ClearColor (0.0f, 0.0f, 0.0f, 1.0f); GL.Clear (ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.Oes.BindVertexArray (vertexArray); // Render the objects with GLKit for (int i = 0; i < (NumCubes + NumStars); i++) { var effect = effects [i]; effect.PrepareToDraw(); GL.DrawArrays (BeginMode.Triangles, 0, 36); } }