예제 #1
0
        public EngineWindow(Form1 f, CLI.DirectZobWrapper directZobWrapper)
        {
            InitializeComponent();
            m_mainForm                  = f;
            m_directZobWrapper          = directZobWrapper;
            m_engineWrapper             = new CLI.EngineWrapper();
            m_width                     = m_engineWrapper.GetBufferWidth();
            m_height                    = m_engineWrapper.GetBufferHeight();
            EngineRender.Width          = m_width;
            EngineRender.Height         = m_height;
            m_EngineGraphics            = EngineRender.CreateGraphics();
            m_engineThread              = new Thread(RunEngineThread);
            m_engineThread.IsBackground = true;
            UpdateEngineWindowDelegate  = new UpdateEngineWindow(UpdateEngineWindowMethod);

            m_engineThread.Start();
            if (OnBeginFrame != null)
            {
                OnBeginFrame(this, EventArgs.Empty);
            }
            m_directZobWrapper.RunAFrame();
            IntPtr p = m_engineWrapper.GetBufferData();

            m_engineBitmap = new System.Drawing.Bitmap(m_width, m_height, 4 * m_width, System.Drawing.Imaging.PixelFormat.Format32bppRgb, p);
            if (OnEndFrame != null)
            {
                OnEndFrame(this, EventArgs.Empty);
            }
        }
예제 #2
0
 private void UpdateEngineWindowMethod()
 {
     //if(m_directZobWrapper.RunAFrame() >= 0)
     {
         IntPtr    p    = m_engineWrapper.GetBufferData();
         Rectangle rect = new Rectangle(0, 0, m_engineBitmap.Width, m_engineBitmap.Height);
         System.Drawing.Imaging.BitmapData bmpData =
             m_engineBitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.WriteOnly,
                                     m_engineBitmap.PixelFormat);
         bmpData.Scan0 = p;
         m_engineBitmap.UnlockBits(bmpData);
         IntPtr hwnd = EngineRender.Handle;
         m_EngineGraphics = Graphics.FromHwnd(hwnd);
         m_EngineGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
         m_EngineGraphics.DrawImage(m_engineBitmap, 0, 0, EngineRender.Width, EngineRender.Height);
     }
     m_mainForm.UpdateAfterEngine();
 }