示例#1
0
        private void RenderControl(RenderEventArgs e, Control ctl)
        {
            if (ctl is Control2D)
            {
                Control2D c2d = (ctl as Control2D);
                Internal.OpenGL.Methods.glMatrixMode(MatrixMode.ModelView);
                Internal.OpenGL.Methods.glTranslated(c2d.Position.X, c2d.Position.Y, 0);
                Internal.OpenGL.Methods.glTranslated(5, 1, 0);
            }

            BeforeRenderEventArgs bre = new BeforeRenderEventArgs(e.Canvas);

            ctl.OnBeforeRender(bre);
            if (bre.Cancel)
            {
                return;
            }

            ctl.OnRender(e);
            ctl.OnAfterRender(e);

            if (ctl is Control2D)
            {
                Control2D c2d = (ctl as Control2D);
                Internal.OpenGL.Methods.glMatrixMode(MatrixMode.ModelView);
                Internal.OpenGL.Methods.glTranslated(-c2d.Position.X, -c2d.Position.Y, 0);
                Internal.OpenGL.Methods.glTranslated(-5, -1, 0);
            }
        }
示例#2
0
 protected virtual void OnBeforeRender(BeforeRenderEventArgs e)
 {
     if (BeforeRender != null)
     {
         BeforeRender(this, e);
     }
 }
示例#3
0
        protected internal override void OnBeforeRender(BeforeRenderEventArgs e)
        {
            base.OnBeforeRender(e);

            // Internal.OpenGL.Methods.glMatrixMode(MatrixMode.ModelView);
            // Internal.OpenGL.Methods.glLoadIdentity();

            e.Canvas.Translate(0, System.Windows.Forms.SystemInformation.CaptionHeight - 4);

            Internal.OpenGL.Methods.glDisable(Internal.OpenGL.Constants.GLCapabilities.Lighting);

            if (HasFocus)
            {
                e.Canvas.Color = Colors.DarkBlue;
            }
            else
            {
                e.Canvas.Color = Colors.Silver;
            }
            e.Canvas.DrawRectangle(0, 0, this.Size.Width, this.Size.Height);
            e.Canvas.FillRectangle(0, 0, this.Size.Width, 20);

            e.Canvas.Color = Color.FromRGBA(Colors.Silver.Red - 0.01, Colors.Silver.Green - 0.01, Colors.Silver.Blue - 0.01);
            e.Canvas.FillRectangle(0, 20, this.Size.Width - 1, this.Size.Height - 20);

            if (HasFocus)
            {
                e.Canvas.Color = Colors.White;
            }
            else
            {
                e.Canvas.Color = Colors.DarkGray;
            }
            e.Canvas.DrawText(mvarTitle, 4, 14);


            e.Canvas.Translate(0, System.Windows.Forms.SystemInformation.CaptionHeight - 4);
        }
示例#4
0
        protected internal override void OnBeforeRender(BeforeRenderEventArgs e)
        {
            base.OnBeforeRender(e);

            // Internal.OpenGL.Methods.glMatrixMode(MatrixMode.ModelView);
            // Internal.OpenGL.Methods.glLoadIdentity();

            e.Canvas.Translate(0, System.Windows.Forms.SystemInformation.CaptionHeight - 4);

            Internal.OpenGL.Methods.glDisable(Internal.OpenGL.Constants.GLCapabilities.Lighting);

            if (HasFocus)
            {
                e.Canvas.Color = Colors.DarkBlue;
            }
            else
            {
                e.Canvas.Color = Colors.Silver;
            }
            e.Canvas.DrawRectangle(0, 0, this.Size.Width, this.Size.Height);
            e.Canvas.FillRectangle(0, 0, this.Size.Width, 20);

            e.Canvas.Color = Color.FromRGBA(Colors.Silver.Red - 0.01, Colors.Silver.Green - 0.01, Colors.Silver.Blue - 0.01);
            e.Canvas.FillRectangle(0, 20, this.Size.Width - 1, this.Size.Height - 20);

            if (HasFocus)
            {
                e.Canvas.Color = Colors.White;
            }
            else
            {
                e.Canvas.Color = Colors.DarkGray;
            }
            e.Canvas.DrawText(mvarTitle, 4, 14);

            e.Canvas.Translate(0, System.Windows.Forms.SystemInformation.CaptionHeight - 4);
        }
示例#5
0
        private static void _OnRender()
        {
            Window w = null;

            if (mvarLastFullscreenWindow != null)
            {
                w = mvarLastFullscreenWindow;
            }
            else
            {
                int handle = Internal.FreeGLUT.Methods.glutGetWindow();
                w = handleWindows[handle];
            }

            BeforeRenderEventArgs bre = new BeforeRenderEventArgs(w.Canvas);
            RenderEventArgs       re  = new RenderEventArgs(w.Canvas);

            Internal.OpenGL.Methods.glMatrixMode(MatrixMode.Projection);
            Internal.OpenGL.Methods.glLoadIdentity();
            Internal.OpenGL.Methods.glViewport(0, 0, w.Width, w.Height);
            Internal.OpenGL.Methods.glOrtho(0, w.Width, w.Height, 0, -1, 1);

            Internal.OpenGL.Methods.glMatrixMode(MatrixMode.ModelView);
            Internal.OpenGL.Methods.glLoadIdentity();

            Internal.OpenGL.Methods.glClearColor(w.BackgroundColor.Red, w.BackgroundColor.Green, w.BackgroundColor.Blue, w.BackgroundColor.Alpha);
            Internal.OpenGL.Methods.glClear(Internal.OpenGL.Constants.GL_COLOR_BUFFER_BIT | Internal.OpenGL.Constants.GL_DEPTH_BUFFER_BIT);

            w.OnBeforeRender(bre);

            if (bre.Cancel)
            {
                return;
            }

            bool depthtest = Internal.OpenGL.Methods.glIsEnabled(Internal.OpenGL.Constants.GLCapabilities.DepthTesting);
            bool lighting  = Internal.OpenGL.Methods.glIsEnabled(Internal.OpenGL.Constants.GLCapabilities.Lighting);

            double ofsx = 1.0, ofsy = 11.0;

            if (w.FullScreen)
            {
                ofsx = 0;
                ofsy = -10;
            }

            foreach (Control ctl in w.Controls)
            {
                if (ctl.Visible)
                {
                    if (ctl is Control2D)
                    {
                        // set up for 2D rendering
                        Caltron.Internal.OpenGL.Methods.glViewport(0, 0, w.Width, w.Height);

                        Control2D c2d = (ctl as Control2D);
                        Internal.OpenGL.Methods.glMatrixMode(MatrixMode.ModelView);
                        Internal.OpenGL.Methods.glLoadIdentity();
                        Internal.OpenGL.Methods.glTranslated((c2d.Position.X + ofsx), (c2d.Position.Y + ofsy), 0);

                        if (depthtest)
                        {
                            Internal.OpenGL.Methods.glDisable(Internal.OpenGL.Constants.GLCapabilities.DepthTesting);
                        }
                        if (lighting)
                        {
                            Internal.OpenGL.Methods.glDisable(Internal.OpenGL.Constants.GLCapabilities.Lighting);
                        }
                    }

                    ctl.OnBeforeRender(bre);
                    if (!bre.Cancel)
                    {
                        ctl.OnRender(re);
                        ctl.OnAfterRender(re);
                    }

                    if (ctl is Control2D)
                    {
                        Control2D c2d = (ctl as Control2D);
                        Internal.OpenGL.Methods.glMatrixMode(MatrixMode.ModelView);
                        Internal.OpenGL.Methods.glTranslated(-(c2d.Position.X + ofsx), -(c2d.Position.Y + ofsy), 0);

                        if (depthtest)
                        {
                            Internal.OpenGL.Methods.glEnable(Internal.OpenGL.Constants.GLCapabilities.DepthTesting);
                        }
                        if (lighting)
                        {
                            Internal.OpenGL.Methods.glEnable(Internal.OpenGL.Constants.GLCapabilities.Lighting);
                        }
                    }
                }
            }

            w.OnAfterRender(re);
            Internal.FreeGLUT.Methods.glutSwapBuffers();
        }
示例#6
0
        private void RenderControl(RenderEventArgs e, Control ctl)
        {
            if (ctl is Control2D)
            {
                Control2D c2d = (ctl as Control2D);
                Internal.OpenGL.Methods.glMatrixMode(MatrixMode.ModelView);
                Internal.OpenGL.Methods.glTranslated(c2d.Position.X, c2d.Position.Y, 0);
                Internal.OpenGL.Methods.glTranslated(5, 1, 0);
            }

            BeforeRenderEventArgs bre = new BeforeRenderEventArgs(e.Canvas);
            ctl.OnBeforeRender(bre);
            if (bre.Cancel) return;

            ctl.OnRender(e);
            ctl.OnAfterRender(e);

            if (ctl is Control2D)
            {
                Control2D c2d = (ctl as Control2D);
                Internal.OpenGL.Methods.glMatrixMode(MatrixMode.ModelView);
                Internal.OpenGL.Methods.glTranslated(-c2d.Position.X, -c2d.Position.Y, 0);
                Internal.OpenGL.Methods.glTranslated(-5, -1, 0);
            }
        }
示例#7
0
        private static void _OnRender()
        {
            Window w = null;
            if (mvarLastFullscreenWindow != null)
            {
                w = mvarLastFullscreenWindow;
            }
            else
            {
                int handle = Internal.FreeGLUT.Methods.glutGetWindow();
                w = handleWindows[handle];
            }

            BeforeRenderEventArgs bre = new BeforeRenderEventArgs(w.Canvas);
            RenderEventArgs re = new RenderEventArgs(w.Canvas);

            Internal.OpenGL.Methods.glMatrixMode(MatrixMode.Projection);
            Internal.OpenGL.Methods.glLoadIdentity();
            Internal.OpenGL.Methods.glViewport(0, 0, w.Width, w.Height);
            Internal.OpenGL.Methods.glOrtho(0, w.Width, w.Height, 0, -1, 1);

            Internal.OpenGL.Methods.glMatrixMode(MatrixMode.ModelView);
            Internal.OpenGL.Methods.glLoadIdentity();

            Internal.OpenGL.Methods.glClearColor(w.BackgroundColor.Red, w.BackgroundColor.Green, w.BackgroundColor.Blue, w.BackgroundColor.Alpha);
            Internal.OpenGL.Methods.glClear(Internal.OpenGL.Constants.GL_COLOR_BUFFER_BIT | Internal.OpenGL.Constants.GL_DEPTH_BUFFER_BIT);

            w.OnBeforeRender(bre);

            if (bre.Cancel) return;

            bool depthtest = Internal.OpenGL.Methods.glIsEnabled(Internal.OpenGL.Constants.GLCapabilities.DepthTesting);
            bool lighting = Internal.OpenGL.Methods.glIsEnabled(Internal.OpenGL.Constants.GLCapabilities.Lighting);

            double ofsx = 1.0, ofsy = 11.0;
            if (w.FullScreen)
            {
                ofsx = 0;
                ofsy = -10;
            }

            foreach (Control ctl in w.Controls)
            {
                if (ctl.Visible)
                {
                    if (ctl is Control2D)
                    {
                        // set up for 2D rendering
                        Caltron.Internal.OpenGL.Methods.glViewport(0, 0, w.Width, w.Height);

                        Control2D c2d = (ctl as Control2D);
                        Internal.OpenGL.Methods.glMatrixMode(MatrixMode.ModelView);
                        Internal.OpenGL.Methods.glLoadIdentity();
                        Internal.OpenGL.Methods.glTranslated((c2d.Position.X + ofsx), (c2d.Position.Y + ofsy), 0);

                        if (depthtest) Internal.OpenGL.Methods.glDisable(Internal.OpenGL.Constants.GLCapabilities.DepthTesting);
                        if (lighting) Internal.OpenGL.Methods.glDisable(Internal.OpenGL.Constants.GLCapabilities.Lighting);
                    }

                    ctl.OnBeforeRender(bre);
                    if (!bre.Cancel)
                    {
                        ctl.OnRender(re);
                        ctl.OnAfterRender(re);
                    }

                    if (ctl is Control2D)
                    {
                        Control2D c2d = (ctl as Control2D);
                        Internal.OpenGL.Methods.glMatrixMode(MatrixMode.ModelView);
                        Internal.OpenGL.Methods.glTranslated(-(c2d.Position.X + ofsx), -(c2d.Position.Y + ofsy), 0);

                        if (depthtest) Internal.OpenGL.Methods.glEnable(Internal.OpenGL.Constants.GLCapabilities.DepthTesting);
                        if (lighting) Internal.OpenGL.Methods.glEnable(Internal.OpenGL.Constants.GLCapabilities.Lighting);
                    }
                }
            }

            w.OnAfterRender(re);
            Internal.FreeGLUT.Methods.glutSwapBuffers();
        }
示例#8
0
 protected virtual void OnBeforeRender(BeforeRenderEventArgs e)
 {
     if (BeforeRender != null) BeforeRender(this, e);
 }