Esempio n. 1
0
        /// <summary>
        /// refreshes the back ground for <see cref="ForeGroundDraw"/>.
        /// </summary>
        public void RefreshBackGround()
        {
            Texture  Savet = texture;
            GLShader S     = Shader;

            BackBuffer.BackGround = BackColor;
            if (BackBuffer.FboHandle <= 0)
            {
                BackBuffer.Init((int)ViewPort.Width, (int)ViewPort.Height);
            }

            RenderKind K = RenderKind;

            RenderKind = RenderKind.Render;
            Matrix P = ProjectionMatrix;

            ProjectionMatrix = Matrix.scale(new xyz(1, -1, 1)) * P;

            //--------- Draw scene to Backbuffer
            BackBuffer.EnableWriting();

            OnPaint();

            BackBuffer.DisableWriting();
            texture          = Savet;
            ProjectionMatrix = P;
            RenderKind       = K;
            Shader           = S;
        }
Esempio n. 2
0
 private void OnLoadControl(object sender, EventArgs e)
 {
     memGraphics.Init(this.CreateGraphics(), this.ClientRectangle.Width, this.ClientRectangle.Height);
 }
Esempio n. 3
0
        /// <summary>
        /// is called when the <see cref="WinControl"/> has changed his size.
        /// </summary>
        /// <param name="width">the new width of the Wincontrol</param>
        /// <param name="height">the new height of the Wincontrol</param>

        protected virtual void OnViewPortChanged(int width, int height)
        {
            //if (FirstViewPortChanged)
            //{ FirstViewPortChanged = false;
            //    OnCreated();
            //    if (this._RenderMode == Mode.Allways)
            //        SetTimer();
            //}
            //    return;
            //CheckError();
            if ((width == 0) || (height == 0))
            {
                return;
            }
            MakeCurrent();
            Matrix old = EyeMatrix(new Size((int)ViewPort.Width, (int)ViewPort.Height), FieldOfView).invert();
            double Fa  = ViewPort.Width / (float)width;
            double Fb  = ViewPort.Height / (float)height;

            ViewPort = new Rectangle(0, 0, width, height);
            ShadowFBO.InitForDepth(ShadowSetting.Width, ShadowSetting.Height);
            CheckError();
            Matrix New = EyeMatrix(new Size(width, height), FieldOfView);
            Matrix M   = ((Matrix.LookAt(Camera.Position, Camera.Position + Camera.Direction, Camera.UpVector)));//* Matrix.Scale(PerspektiveFactor, PerspektiveFactor, PerspektiveFactor));

            if (FieldOfView == 0)
            {
                Fa = 1; Fb = 1;
            }
            ProjectionMatrix = Matrix.Scale(Fa, Fb, 1) * ProjectionMatrix * M.invert() * old * New * M;

            Camera.MakeConsistent();
            if (FirstViewPortChanged)
            {
                Camera.setDefZoom();
                FirstViewPortChanged = false;
                Shader = SmallShader;



                OnCreated();
                SizeChanged();
                if (this._RenderMode == Mode.Allways)
                {
                    SetTimer();
                }
            }

            try
            {
                if (ForegroundDrawEnable)
                {
                    BackBuffer.Init(width, height);
                    RefreshBackGround();
                    CopyFromBackGround();
                }
            }
            catch (System.Exception)
            {
                _ForegroundDrawEnable = false;
            }

            CheckError();
        }