public bool CreateGraphicsContext(IntPtr hwnd, ref PresentationParameters pp)
        {
            //define presentation parameters
            pp = new PresentationParameters();
            pp.BackBufferFormat   = SurfaceFormat.Color;
            pp.DeviceWindowHandle = hwnd;
            pp.IsFullScreen       = false;
            pp.BackBufferHeight   = Control.FromHandle(hwnd).Height;
            pp.BackBufferWidth    = Control.FromHandle(hwnd).Width;
            //Initialize Z-buffer - need this for winform
            pp.DepthStencilFormat = DepthFormat.Depth24;

            if (m_GraphicsDevice != null)
            {
                return(false);
            }
            //create an XNA graphics device
            m_GraphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter,
                                                  GraphicsProfile.HiDef,
                                                  pp);

            m_DefaultState                   = new RasterizerState();
            m_DefaultState.CullMode          = CullMode.None;
            m_DefaultState.FillMode          = FillMode.Solid;
            m_GraphicsDevice.RasterizerState = m_DefaultState;

            //check if graphics device was created
            Debug.Assert(m_GraphicsDevice != null, "XNA Graphics Device did not Initialize");

            m_GraphicsDevice.Reset();
            m_GraphicsDevice.DepthStencilState = DepthStencilState.Default;

            RGraphicsDeviceService gS = new RGraphicsDeviceService();

            gS.GraphicsDevice = m_GraphicsDevice;
            mService          = new RGameView();
            mService.SetService(gS);
            mResources = new ContentManager(mService);
            mResources.RootDirectory = "./Content/";

            Initialize();

            return(true);
        }
        public bool CreateGraphicsContext(IntPtr hwnd, ref PresentationParameters pp)
        {
            //define presentation parameters
            pp = new PresentationParameters();
            pp.BackBufferFormat = SurfaceFormat.Color;
            pp.DeviceWindowHandle = hwnd;
            pp.IsFullScreen = false;
            pp.BackBufferHeight = Control.FromHandle(hwnd).Height;
            pp.BackBufferWidth = Control.FromHandle(hwnd).Width;
            //Initialize Z-buffer - need this for winform
            pp.DepthStencilFormat = DepthFormat.Depth24;

            if (m_GraphicsDevice != null)
                return false;
            //create an XNA graphics device
            m_GraphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter,
                    GraphicsProfile.HiDef,
                    pp);

            m_DefaultState = new RasterizerState();
            m_DefaultState.CullMode = CullMode.None;
            m_DefaultState.FillMode = FillMode.Solid;
            m_GraphicsDevice.RasterizerState = m_DefaultState;

            //check if graphics device was created
            Debug.Assert(m_GraphicsDevice != null, "XNA Graphics Device did not Initialize");

            m_GraphicsDevice.Reset();
            m_GraphicsDevice.DepthStencilState = DepthStencilState.Default;

            RGraphicsDeviceService gS = new RGraphicsDeviceService();
            gS.GraphicsDevice = m_GraphicsDevice;
            mService = new RGameView();
            mService.SetService(gS);
            mResources = new ContentManager(mService);
            mResources.RootDirectory = "./Content/";

            Initialize();

            return true;
        }