Example #1
0
        public void Render(long time, rectangle r)
        {
            var c  = (test++ % 25) / 25f;
            var cc = new Color(c, c, c, 255);

            //GL.Viewport(0, 0, r.width, r.height);
            GL.ClearColor((float)cc.Red, (float)cc.Green, (float)cc.Blue, (float)cc.Alpha);
            GL.Clear(ClearBufferMask.ColorBufferBit /*ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit*/); // We're not using stencil buffer so why bother with clearing?

#if TRIANGLE
            this.vertices.Apply(this.shader);
            GL.DrawArrays(BeginMode.Triangles, 0, 3);     // Starting from vertex 0; 3 vertices total -> 1 triangle
#else
            //   this.vertices.Apply(this.shader);

            if (this.frame != null)
            {
                GL.BindTexture(TextureTarget.Texture2D, (this.frame.Buffer as IOpenGLFrame).Textures[0]);

                this.vertices.Apply(this.shader);

                GL.DrawArrays(BeginMode.Triangles, 0, 6); // Starting from vertex 0; 6 vertices total -> 2 triangle
                GL.DisableVertexAttribArray(0);

                frame.Dispose();
                frame = null;
            }
#endif
        }
Example #2
0
        void IRenderOwner.render(IRenderFrame destination, long time, Rectangle r)
        {
            // var state = this.Renderer.StartRender(destination, r);

            var c  = (test++ % 25) / 25f;
            var cc = new Xwt.Drawing.Color(c, c, c, 255);

            GL.ClearColor((float)cc.Red, (float)cc.Green, (float)cc.Blue, (float)cc.Alpha);
            GL.Clear(ClearBufferMask.ColorBufferBit /*ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit*/);    // We're not using stencil buffer so why bother with clearing?

            this.verticestex.Apply(this.shadertex);

            if (frame != null)
            {
                GL.BindTexture(TextureTarget.Texture2D, (frame.Buffer as IOpenGLFrame).Textures[0]);

                // this.vertices.Apply(this.shader);

                GL.DrawArrays(BeginMode.Triangles, 0, 6);     // Starting from vertex 0; 3 vertices total -> 2 triangle
                GL.DisableVertexAttribArray(0);

                frame.Dispose();
                frame = null;
            }
            //  this.Renderer.EndRender(state);

            this.Renderer.Present(destination, r, IntPtr.Zero);
        }
Example #3
0
        public bool StartRender(long time, bool dowait)
        {
#if TRIANGLE
            return(true);
#else
            this.frame = this.MoviePlayer?.GetFrame(time, 0);
            return(frame != null);
#endif
        }
Example #4
0
        /// <summary>
        /// fill from avframe to renderbuffer
        /// </summary>
        /// <param name="renderbuffer"></param>
        public void Update(ref frameinfo renderbuffer, IntPtr avframe)
        {
            if (renderbuffer == null)
            {
                renderbuffer = new frameinfo(_renderer, _video, _player);
                //this.Frame = this._video.AllocateFrame(this.allocfunc, this.lockfunc, this.unlockfunc);
                //this.Buffer = this._renderer.GetFrame();
            }
            this._video.FillFrame(renderbuffer.Frame, avframe);

            // this._lasttime = frame.Frame.Time;

            renderbuffer.Frame.Time += _video.Frame(this._player.basetime, this._player.timebase);
        }
Example #5
0
 private void Dispose(bool disposing)
 {
     using (var ll = this.renderer.GetDrawLock())
     {
         foreach (var f in this.frames)
         {
             f.Dispose();
         }
         this.frames.Clear();
         this.framebuffer?.Dispose();
         this.framebuffer = null;
     }
     if (this.audiobuffer != null)
     {
         this.mixer.Unregister(this.audiobuffer);
     }
     this.player?.Dispose();
 }
Example #6
0
        private bool frameready(IntPtr avframe, long time, long duration)
        {
            if (video.Time(time, this.timebase) < this.starttime)
            {
                return(false);
            }
            if (WaitHandle.WaitAny(new WaitHandle[] { this.stopevent, this.emptyevent }, -1, false) == 1)
            {
                frameinfo frame;
                frame = new frameinfo(this.renderer, video, this, avframe, time, duration);
                lock (frames)
                {
                    frames.Add(frame);
                    this.readyevent.Set();

                    if (frames.Count >= buffertotal)
                    {
                        this.emptyevent.Reset();
                    }
                }
                return(true);
            }
            return(false);
        }
Example #7
0
        bool IRenderOwner.preparerender(IRenderFrame destination, long time, bool dowait)
        {
            this.frame = this.MoviePlayer?.GetFrame(time, 0);

            return(frame != null);
        }
Example #8
0
 /// <summary>
 /// fill from avframe to renderbuffer
 /// </summary>
 /// <param name="renderbuffer"></param>
 public void Update(ref frameinfo renderbuffer)
 {
     Update(ref renderbuffer, this._avframe);
 }