Beispiel #1
0
        void ICanvas.ShowView(IView toShow)
        {
            if (paintTo3D is PaintToOpenGL openGL)
            {
                openGL.Disconnect(this);
            }
            view = toShow;
            switch (toShow.PaintType)
            {
            case "GDI":
                // create the GDI paint machine
                this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true);
                this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
                paintTo3D = new PaintToGDI(toShow.Projection, this.CreateGraphics());
                break;

            case "3D":
            default:
            {
                // create the OpenGL machine
                this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true);
                this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
                this.DoubleBuffered = false;
                PaintToOpenGL paintToOpenGL = new PaintToOpenGL(1e-6);
                paintToOpenGL.Init(this);
                paintTo3D = paintToOpenGL;
            }
            break;
            }
            view.Connect(this);
            Invalidate();
        }
Beispiel #2
0
        IPaintTo3D IUIService.CreatePaintInterface(Bitmap paintToBitmap, double precision)
        {
            System.Drawing.Graphics gr        = System.Drawing.Graphics.FromImage(paintToBitmap);
            PaintToOpenGL           paintTo3D = new PaintToOpenGL(precision);
            IntPtr dc = gr.GetHdc();

            paintTo3D.Init(dc, paintToBitmap.Width, paintToBitmap.Height, true);
            return(paintTo3D);
        }