Exemplo n.º 1
0
 public override void DrawRenderBitmap(RenderBitmap bmp)
 {
     if (!(bmp is RenderBitmap1))
     {
         return;
     }
     renderTarget.DrawBitmap(((RenderBitmap1)bmp).GetBitmap(), 1, BitmapInterpolationMode.Linear);
 }
Exemplo n.º 2
0
 public override void DrawRenderBitmap(RenderBitmap bmp)
 {
     if (!(bmp is RenderBitmap2))
     {
         return;
     }
     g.DrawImage(((RenderBitmap2)bmp).GetBuffer(), new PointF(0, 0));
 }
Exemplo n.º 3
0
 public override void SetRenderTarget(RenderBitmap bmp)
 {
     if (bmp == null || !(bmp is RenderBitmap1))
     {
         renderTarget = mainRenderTarget;
     }
     else
     {
         renderTarget = ((RenderBitmap1)bmp).GetRenderTarget();
     }
 }
Exemplo n.º 4
0
 public override void SetRenderTarget(RenderBitmap bmp)
 {
     if (bmp == null || !(bmp is RenderBitmap3))
     {
         NativeGL.nglBindFramebuffer(0);
     }
     else
     {
         ((RenderBitmap3)bmp).FBO.Bind();
     }
 }
Exemplo n.º 5
0
 public override void SetRenderTarget(RenderBitmap bmp)
 {
     if (bmp != null && bmp is RenderBitmap2)
     {
         RenderBitmap2 bmp2 = (RenderBitmap2)bmp;
         g = bmp2.GetGraphics();
         r = g.GetRenderer();
     }
     else
     {
         g = mainG;
         r = g.GetRenderer();
     }
 }
Exemplo n.º 6
0
        public override void DrawRenderBitmap(RenderBitmap bmp)
        {
            float x1 = 0, y1 = 0, x2 = Width, y2 = Height;

            if (bmp == null || !(bmp is RenderBitmap3))
            {
                return;
            }

            Opengl32.glEnable(GLConsts.GL_TEXTURE_2D);
            Opengl32.glBindTexture(GLConsts.GL_TEXTURE_2D, ((RenderBitmap3)bmp).FBO.Texture);

            GL.Color(1, 1, 1, 1);
            GL.Begin(PrimitiveType.QUADS);
            GL.TexCoord(0, 1); GL.Vertex2(x1, y1);
            GL.TexCoord(1, 1); GL.Vertex2(x2, y1);
            GL.TexCoord(1, 0); GL.Vertex2(x2, y2);
            GL.TexCoord(0, 0); GL.Vertex2(x1, y2);
            GL.End();
            Opengl32.glDisable(GLConsts.GL_TEXTURE_2D);
        }
Exemplo n.º 7
0
 public abstract void DrawRenderBitmap(RenderBitmap bmp);
Exemplo n.º 8
0
 public abstract void SetRenderTarget(RenderBitmap bmp);
Exemplo n.º 9
0
        void renderLoop()
        {
            gpuRenderer.Init();
            while (running)
            {
                if (redraw || fullredraw || targetTransform != null)
                {
                    if (lockDraw)
                    {
                        waiting = true;
                        continue;
                    }
                    try
                    {
                        Matrix3x3 mat = transform;
                        if (targetTransform != null)
                        {
                            targetT += .03f;
                            if (targetT < 1)
                            {
                                mat = Matrix3x3.Slerp(transform, targetTransform, -(float)Math.Cos(targetT * Math.PI) * .5f + .5f);
                            }
                            else
                            {
                                fullredraw      = true;
                                transform       = mat = targetTransform;
                                targetTransform = null;
                            }

                            if (Configuration.RefreshOnTransform)
                            {
                                fullredraw = true;
                            }
                        }
                        Matrix3x3 tMat = mat.Clone();
                        Matrix3x3 dMat = (stableTransform.GetInverse() * mat).Clone();

                        waiting = false;
                        redraw  = false;
                        //if (this.Height <= 0 || this.Width <= 0) return;
                        int vW = (int)(this.Width * BufferSize);
                        int vH = (int)(this.Height * BufferSize);
                        if (rbmp == null || vW != gpuRenderer.Width || vH != gpuRenderer.Height)
                        {
                            gpuRenderer.Resize(new Size(vW, vH));
                            rbmp?.Dispose();
                            rbmp = gpuRenderer.CreateRenderTarget();
                        }
                        if (!gpuRenderer.Begin(Style.Default.Background))
                        {
                            return;
                        }
                        SizeF pSize = page.Format.GetPixelSize();
                        if (fullredraw)
                        {
                            stableTransform = transform;
                            dMat            = new Matrix3x3();
                            rbmp.Begin();
                            fullredraw = false;
                            gpuRenderer.SetRenderTarget(rbmp);
                            gpuRenderer.Begin(SystemColors.ControlDark);
                            gpuRenderer.ResetTransform();
                            gpuRenderer.Transform(tMat);

                            if (page.OriginalPage == null)
                            {
                                if (page.BackgroundImage == null)
                                {
                                    gpuRenderer.FillRectangle(Util.ApplyFilter(Color.White, Page.Filter), new RectangleF(
                                                                  0, 0, pSize.Width, pSize.Height));
                                }
                                else
                                {
                                    gpuRenderer.DrawImage(page.BackgroundImage,
                                                          new RectangleF(0, 0, pSize.Width, pSize.Height));
                                }
                            }
                            else
                            {
                                gpuRenderer.FillRectangle(Color.White, new RectangleF(
                                                              0, 0, pSize.Width, pSize.Height));
                            }

                            page.DrawBackground(gpuRenderer);

                            if (page.OriginalPage != null &&
                                page.BackgroundImage != null)
                            {
                                gpuRenderer.DrawImage(page.BackgroundImage,
                                                      new RectangleF(0, 0, pSize.Width, pSize.Height));
                            }

                            page.Draw(gpuRenderer);
                            rbmp.End();
                            gpuRenderer.SetRenderTarget(null);
                            tmpLine = null;
                        }

                        gpuRenderer.ResetTransform();
                        gpuRenderer.Transform(dMat);
                        gpuRenderer.DrawRenderBitmap(rbmp);
                        gpuRenderer.ResetTransform();
                        gpuRenderer.Transform(tMat);
                        gpuRenderer.DrawRect(Color.Black, 1, new RectangleF(0, 0, pSize.Width, pSize.Height));
                        if (tmpLine != null)
                        {
                            tmpLine.Render(gpuRenderer);
                        }
                        if (line != null)
                        {
                            line.Render(gpuRenderer);
                        }
                        if (selections != null)
                        {
                            lock (selections)
                            {
                                PointF[] pts = selections.ToArray();
                                transform.GetInverse().Transform(pts);
                                gpuRenderer.DrawDashPolygon(pts);
                            }
                        }

                        // Screen Objects
                        foreach (BaseScreenObject bso in ScreenObjects)
                        {
                            gpuRenderer.ResetTransform();
                            bso.Draw(gpuRenderer, this.Width, this.Height);
                        }

                        gpuRenderer.ResetTransform();
                        gpuRenderer.Transform(Matrix3x3.Translation(0, 0));
                        gpuRenderer.DrawLine(Color.Black, 3, new PointF(0, 0), new PointF(this.Width, 0));
                        Renderer.Effects.DrawShadow(gpuRenderer, new RectangleF(0, 0, Width, 16));
                        if (Configuration.LeftHanded)
                        {
                            gpuRenderer.DrawLine(Color.Black, 3, new PointF(this.Width, 0), new PointF(this.Width, this.Height));
                            gpuRenderer.Transform(Matrix3x3.RotateD(-90));
                            gpuRenderer.Transform(Matrix3x3.Translation(Width, 0));
                            Renderer.Effects.DrawShadow(gpuRenderer, new RectangleF(0, 0, Height, 16));
                            gpuRenderer.ResetTransform();
                        }
                        else
                        {
                            gpuRenderer.DrawLine(Color.Black, 3, new PointF(0, 0), new PointF(0, this.Height));
                            gpuRenderer.Transform(Matrix3x3.RotateD(90));
                            Renderer.Effects.DrawShadow(gpuRenderer, new RectangleF(0, 0, -Height, 16));
                            gpuRenderer.ResetTransform();
                        }

                        Control _p = Parent;
                        Form    _parentForm;
                        while (!(_p is Form))
                        {
                            _p = _p.Parent;
                        }
                        _parentForm = (Form)_p;

                        if (_parentForm.FormBorderStyle == FormBorderStyle.None)
                        {
                            string fullscreenInfo = "";
                            if (Configuration.ShowBattery)
                            {
                                fullscreenInfo += Language.GetText("Overlay.battery") + ": " + (int)(SystemInformation.PowerStatus.BatteryLifePercent * 100) + "%\n";
                            }
                            if (Configuration.ShowTime)
                            {
                                fullscreenInfo += Language.GetText("Overlay.time") + ": " + DateTime.Now.ToShortTimeString() + "\n";
                            }
                            if (Configuration.ShowDate)
                            {
                                fullscreenInfo += Language.GetText("Overlay.date") + ": " + DateTime.Now.ToShortDateString() + "\n";
                            }

                            if (fullscreenInfo.Length > 1)
                            {
                                SizeF      size = CreateGraphics().MeasureString(fullscreenInfo, new Font("Calibri", Util.MmToPoint(5)));
                                RectangleF rect = new RectangleF(Width - size.Width - 16, Height - size.Height - 16, size.Width, size.Height);
                                gpuRenderer.FillRectangle(Color.Black, rect);
                                gpuRenderer.DrawText(fullscreenInfo,
                                                     new PointF(Util.PointToMm(rect.X), Util.PointToMm(rect.Y)),
                                                     5, Color.White);
                            }
                        }

                        if (rBounds.Equals(RectangleF.Empty))
                        {
                            gpuRenderer.End();
                        }
                        else
                        {
                            gpuRenderer.End(rBounds);
                        }
                    }
                    catch (InvalidOperationException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    catch (FieldAccessException)
                    {
                        gpuRenderer.End();
                    }
                }
                Thread.Sleep(10);
            }
            gpuRenderer.Dispose();
        }