예제 #1
0
        public void BeginDraw(GLControl control, int windowSizeY)
        {
#if FAMISTUDIO_LINUX
            var lineWidths = new float[2];
            GL.GetFloat(GetPName.LineWidthRange, lineWidths);
            supportsLineWidth = lineWidths[1] > 1.0f;
#endif

            this.windowSizeY = windowSizeY;
            this.control     = control;

            var controlRect = FlipRectangleY(new Rectangle(control.Left, control.Top, control.Width, control.Height));

            GL.Viewport(controlRect.Left, controlRect.Top, controlRect.Width, controlRect.Height);
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(0, control.Width, control.Height, 0, -1, 1);
            GL.Disable(EnableCap.CullFace);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
            GL.Enable(EnableCap.Blend);

            transform = new Vector4(1, 1, 0, 0);
            scissor   = controlRect;
            GL.Enable(EnableCap.ScissorTest);
            GL.Scissor(scissor.Left, scissor.Top, scissor.Width, scissor.Height);
        }
예제 #2
0
        private bool IsPointInControl(GLControl ctrl, int x, int y, out int ctrlX, out int ctrlY)
        {
            ctrlX = x - ctrl.Left;
            ctrlY = y - ctrl.Top;

            if (ctrlX >= 0 &&
                ctrlY >= 0 &&
                ctrlX < ctrl.Width &&
                ctrlY < ctrl.Height)
            {
                return(true);
            }

            return(false);
        }
예제 #3
0
        public void Tick(float timeDelta)
        {
            if (transitionTimer > 0.0f)
            {
                var prevTimer = transitionTimer;
                transitionTimer = Math.Max(0.0f, transitionTimer - timeDelta * 6);

                if (prevTimer > 0.5f && transitionTimer <= 0.5f)
                {
                    activeControl     = transitionControl;
                    transitionControl = null;
                    UpdateLayout(true);
                }

                MarkDirty();
            }
        }
예제 #4
0
        // Some OpenGL implementation applies sRGB to the alpha channel which is super
        // wrong. We can detect that assuming the gradient we draw should be at 50%
        // opacity in the middle.
        bool DetectBadOpenGLAlpha(GLControl ctrl, RenderGraphics g, byte[] videoImage)
        {
            var blackGradientBrush = g.CreateVerticalGradientBrush(0, 256, Color.FromArgb(255, 0, 0, 0), Color.FromArgb(0, 0, 0, 0));

            g.BeginDraw(ctrl, videoResY);
            g.Clear(Color.FromArgb(0, 0, 0, 0));
            g.FillRectangle(0, 0, videoResX, 256, blackGradientBrush);
            g.EndDraw();
            g.GetBitmap(videoImage);

            blackGradientBrush.Dispose();

            float midGradientAlpha = videoImage[128 * videoResX * 4 + 3] / 255.0f;
            float diff             = Math.Abs(midGradientAlpha - 0.5f);

            return(diff > 0.05f);
        }
예제 #5
0
        public void SetActiveControl(GLControl ctrl, bool animate = true)
        {
            if (activeControl != ctrl)
            {
                Debug.Assert(transitionTimer == 0.0f && transitionControl == null);

                if (animate)
                {
                    transitionControl = ctrl;
                    transitionTimer   = 1.0f;
                }
                else
                {
                    activeControl   = ctrl;
                    transitionTimer = 0.0f;
                }
            }
        }
예제 #6
0
        private void RenderControl(GLControl ctrl)
        {
            var fullscreenViewport = ctrl.WantsFullScreenViewport;

            if (fullscreenViewport)
            {
                gfx.BeginDrawControl(new System.Drawing.Rectangle(0, 0, width, height), height);
            }
            else
            {
                gfx.BeginDrawControl(new System.Drawing.Rectangle(ctrl.Left, ctrl.Top, ctrl.Width, ctrl.Height), height);
            }

            gfx.SetLineBias(2);

            if (fullscreenViewport)
            {
                gfx.Transform.PushTranslation(ctrl.Left, ctrl.Top);
            }

            var t0 = DateTime.Now;

            ctrl.Render(gfx);
            var t1 = DateTime.Now;

            if (ShowRenderingTimes)
            {
                var cmd = gfx.CreateCommandList();
                cmd.DrawText($"{(t1 - t0).TotalMilliseconds}", res.FontVeryLargeBold, 10, 10, gfx.GetSolidBrush(System.Drawing.Color.SpringGreen));
                gfx.DrawCommandList(cmd);
            }

            if (fullscreenViewport)
            {
                gfx.Transform.PopTransform();
            }

            gfx.EndDrawControl();

            ctrl.ClearDirtyFlag();
        }
예제 #7
0
        public void BeginDraw(GLControl control, int windowSizeY)
        {
            this.windowSizeY = windowSizeY;
            this.control     = control;

            var controlRect = FlipRectangleY(new Rectangle(control.Left, control.Top, control.Width, control.Height));

            GL.Viewport(controlRect.Left, controlRect.Top, controlRect.Width, controlRect.Height);
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(0, control.Width, control.Height, 0, -1, 1);
            GL.Disable(EnableCap.CullFace);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
            GL.Enable(EnableCap.Blend);

            translation = new Point(0, 0);
            scissor     = controlRect;
            GL.Enable(EnableCap.ScissorTest);
            GL.Scissor(scissor.Left, scissor.Top, scissor.Width, scissor.Height);
        }
예제 #8
0
        public FamiStudioControls(FamiStudioForm parent)
        {
            toolbar         = new Toolbar();
            sequencer       = new Sequencer();
            pianoRoll       = new PianoRoll();
            projectExplorer = new ProjectExplorer();
            quickAccessBar  = new QuickAccessBar();
            mobilePiano     = new MobilePiano();

            controls[0] = sequencer;
            controls[1] = pianoRoll;
            controls[2] = projectExplorer;
            controls[3] = quickAccessBar;
            controls[4] = toolbar;
            controls[5] = mobilePiano;

            activeControl = sequencer;

            foreach (var ctrl in controls)
            {
                ctrl.ParentForm = parent;
            }
        }
예제 #9
0
 public virtual void EndDraw()
 {
     control = null;
 }
예제 #10
0
 public DeferredEvent(DeferredEventType t, GLControl c, EventArgs e)
 {
     type = t;
     ctrl = c;
     args = e;
 }
예제 #11
0
 public void EndDraw()
 {
     control = null;
 }