예제 #1
0
        public void Attach(RenderingSurface xiSurface)
        {
            if (xiSurface.IsInDesignMode)
            {
                return;
            }

            Detach();

            mSurface = xiSurface;

            try
            {
                mRenderingContext = Wgl.wglCreateContext(mSurface.DeviceContext);
                if (mRenderingContext == IntPtr.Zero)
                {
                    throw new Exception("Could not create rendering context");
                }

                lock (mRenderingContexts)
                {
                    if (mRenderingContexts.Count != 0)
                    {
                        Wgl.wglShareLists(mRenderingContexts[0], mRenderingContext);
                    }

                    mRenderingContexts.Add(mRenderingContext);
                }
            }
            catch
            {
                Detach();
                throw;
            }

            mSurface.Resize += Surface_Resize;
            mSurface.ReleaseDeviceContext += Surface_ReleaseDeviceContext;
            mSurface.Paint += Surface_Paint;

            SetViewPort(mSurface.Width, mSurface.Height);

            Init();
        }
예제 #2
0
 void Viewer3DRenderingSurface_GotFocus(object sender, EventArgs e)
 {
     mActiveSurface = sender as RenderingSurface;
 }
예제 #3
0
        void CreateView(RenderingSurface xiSurface, Scene xiScene, Camera xiCamera, RenderMode xiFixedRenderMode)
        {
            xiSurface.MouseDown += new MouseEventHandler(Viewer3DRenderingSurface_MouseDown);
              xiSurface.MouseUp += new MouseEventHandler(Viewer3DRenderingSurface_MouseUp);
              xiSurface.MouseMove += new MouseEventHandler(Viewer3DRenderingSurface_MouseMove);
              xiSurface.MouseWheel += new MouseEventHandler(Viewer3DRenderingSurface_MouseWheel);
              xiSurface.GotFocus += new EventHandler(Viewer3DRenderingSurface_GotFocus);

              ImmediateModeRenderer lRenderer = new ImmediateModeRenderer();
              lRenderer.FixedRenderMode = xiFixedRenderMode;
              lRenderer.Attach(xiSurface);

              MMEdEditorView lView = new MMEdEditorView(this, xiScene, xiCamera, lRenderer);

              mViews.Add(xiSurface, lView);
        }