Example #1
0
        protected internal override void OnRender(RenderEventArgs e)
        {
            base.OnRender(e);

            e.Canvas.Color = Colors.Silver;
            e.Canvas.DrawSquare(0, 0, 400, 300);
        }
Example #2
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);
            }
        }
Example #3
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();
        }
Example #4
0
        protected internal override void OnRender(RenderEventArgs e)
        {
            base.OnRender(e);

            List<Controls.Controls2D.Popup> popups = new List<Controls.Controls2D.Popup>();
            foreach (Control ctl in mvarControls)
            {
                if (!ctl.Visible) continue;
                if (ctl is Controls.Controls2D.Popup)
                {
                    popups.Add(ctl as Controls.Controls2D.Popup);
                    continue;
                }

                RenderControl(e, ctl);
            }
            foreach (Controls.Controls2D.Popup popup in popups)
            {
                RenderControl(e, popup);
            }
        }
Example #5
0
 protected virtual void OnAfterRender(RenderEventArgs e)
 {
     if (AfterRender != null) AfterRender(this, e);
 }