当前位置: 首页>>代码示例>>C#>>正文


C# Device.GetBackBuffer方法代码示例

本文整理汇总了C#中Device.GetBackBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# Device.GetBackBuffer方法的具体用法?C# Device.GetBackBuffer怎么用?C# Device.GetBackBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Device的用法示例。


在下文中一共展示了Device.GetBackBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MafiaVideo

        public MafiaVideo(Form form, bool fullscreen)
        {
            this.form = form;
            this.fullscreen = fullscreen;

            if (fullscreen)
            {
                form.FormBorderStyle = FormBorderStyle.None;
            }
            else
            {
                form.FormBorderStyle = FormBorderStyle.Sizable;
            }

            try
            {
                device = new Device(0, DeviceType.Hardware, form, CreateFlags.HardwareVertexProcessing, GetDefaultPresentParameters(fullscreen));
            }
            catch (InvalidCallException)
            {
                try
                {
                    device = new Device(0, DeviceType.Hardware, form, CreateFlags.SoftwareVertexProcessing, GetDefaultPresentParameters(fullscreen));
                }
                catch (InvalidCallException)
                {
                    try
                    {
                        device = new Device(0, DeviceType.Software, form, CreateFlags.SoftwareVertexProcessing, GetDefaultPresentParameters(fullscreen));
                    }
                    catch (InvalidCallException)
                    {
                        throw new Exception("Direct3Dデバイスの生成に失敗しました。");
                    }
                }
            }
            deviceLost = new EventHandler(OnDeviceLost);
            deviceReset = new EventHandler(OnDeviceReset);
            deviceResizing = new CancelEventHandler(OnDeviceResizing);
            device.DeviceLost += deviceLost;
            device.DeviceReset += deviceReset;
            device.DeviceResizing += deviceResizing;
            device.Clear(ClearFlags.Target, Color.FromArgb(212, 208, 200), 0.0f, 0);

            sprite = new Sprite(device);

            backBuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono);
            offScreenImage = new Texture(device, Mafia.SCREEN_WIDTH, Mafia.SCREEN_HEIGHT, 1, Usage.RenderTarget, Manager.Adapters[0].CurrentDisplayMode.Format, Pool.Default);
            offScreenSurface = offScreenImage.GetSurfaceLevel(0);

            texture = MafiaLoader.DefaultLoader.GetTexture(device, "mafia.bmp");

            if (fullscreen)
            {
                Cursor.Hide();
            }

            // form.ClientSize = new Size(Mafia.SCREEN_WIDTH, Mafia.SCREEN_HEIGHT);
            form.ClientSize = new Size(Mafia.SCREEN_WIDTH * 2, Mafia.SCREEN_HEIGHT * 2);
        }
开发者ID:sinshu,项目名称:mafia,代码行数:60,代码来源:MafiaVideo.cs

示例2: drawBackGround

 public void drawBackGround(Device i_dev)
 {
     //背景描画
     Surface dest_surface = i_dev.GetBackBuffer(0, BackBufferType.Mono);
     Viewport vp = i_dev.Viewport;
     i_dev.StretchRectangle(this._surface, this._src_rect, dest_surface, new Rectangle(vp.X, vp.Y, vp.Width, vp.Height), TextureFilter.None);
     return;
 }
开发者ID:whztt07,项目名称:NyARToolkitCS,代码行数:8,代码来源:D3dBackground.cs

示例3: drawBackground

        /// <summary>
        /// バックグラウンドにラスタを描画します。
        /// </summary>
        /// <param name="i_gl"></param>
        /// <param name="i_bg_image"></param>
        public void drawBackground(Device i_dev, INyARRgbRaster i_bg_image)
	    {
            NyARIntSize s = i_bg_image.getSize();
            if(this._surface==null){
                this._surface = new NyARD3dSurface(i_dev,s.w,s.h);
            }else if(!this._surface.isEqualSize(i_bg_image.getSize())){
                //サーフェイスの再構築
                this._surface.Dispose();
                this._surface = new NyARD3dSurface(i_dev, this._screen_size.w, this._screen_size.h);
            }
            this._surface.setRaster(i_bg_image);
            Surface dest_surface = i_dev.GetBackBuffer(0, 0, BackBufferType.Mono);
            Rectangle rect = new Rectangle(0, 0, this._screen_size.w, this._screen_size.h);
            i_dev.StretchRectangle((Surface)this._surface, rect, dest_surface, rect, TextureFilter.None);
	    }
开发者ID:whztt07,项目名称:NyARToolkitCS,代码行数:20,代码来源:NyARD3dRender.cs

示例4: Init

        public int Init(Device d3dDev)
        {
            try
              {
            d3dDev.RenderState.CullMode = Cull.None;
            d3dDev.RenderState.Lighting = false;

            d3dDev.RenderState.AlphaBlendEnable = true;
            d3dDev.RenderState.SourceBlend = Blend.SourceAlpha;
            d3dDev.RenderState.DestinationBlend = Blend.InvSourceAlpha;
            d3dDev.RenderState.AlphaTestEnable = true;
            d3dDev.RenderState.ReferenceAlpha = 0x10;
            d3dDev.RenderState.AlphaFunction = Compare.Greater;

            d3dDev.SamplerState[0].AddressU = TextureAddress.Clamp;
            d3dDev.SamplerState[0].AddressV = TextureAddress.Clamp;
            d3dDev.SamplerState[0].MagFilter = TextureFilter.Linear;
            d3dDev.SamplerState[0].MinFilter = TextureFilter.Linear;
            d3dDev.SamplerState[0].MipFilter = TextureFilter.Linear;

            vertexBuffer = new VertexBuffer(
              typeof(CustomVertex.PositionColoredTextured),
              4,
              d3dDev,
              Usage.WriteOnly,
              CustomVertex.PositionColoredTextured.Format,
              Pool.Managed
              );

            Surface backBuffer = d3dDev.GetBackBuffer(0, 0, BackBufferType.Mono);
            SurfaceDescription backBufferDesc = backBuffer.Description;

            float aspect = (float)backBufferDesc.Width / (float)backBufferDesc.Height;
            Matrix matProj = Matrix.PerspectiveFovLH((float)Math.PI / 4, aspect, 1.0f, 100.0f);
            d3dDev.SetTransform(TransformType.Projection, matProj);

            Vector3 from = new Vector3(1.0f, 1.0f, -3.0f);
            Vector3 at = new Vector3(0.0f, 0.0f, 0.0f);
            Vector3 up = new Vector3(0.0f, 1.0f, 0.0f);
            Matrix matView = Matrix.LookAtLH(from, at, up);
            d3dDev.SetTransform(TransformType.View, matView);

            time = GetTickCount();

            backBuffer.Dispose();
              }
              catch(DirectXException e)
              {
            return e.ErrorCode;
              }
              catch
              {
            return E_FAIL;
              }

              return 0;
        }
开发者ID:coolsula,项目名称:vidplaycorder,代码行数:57,代码来源:PlaneScene.cs

示例5: InitializeDirect3D

        public bool InitializeDirect3D()
        {
            try
            {
                PresentParameters presentParams = new PresentParameters();
                presentParams.Windowed = true; //指定以Windows窗体形式显示
                presentParams.SwapEffect = SwapEffect.Discard; //当前屏幕绘制后它将自动从内存中删除
                presentParams.BackBufferFormat = Format.Unknown;
                presentParams.BackBufferHeight = mImageRect.Height;
                presentParams.BackBufferWidth = mImageRect.Width;
                presentParams.BackBufferCount = 1;
                presentParams.PresentFlag = PresentFlag.LockableBackBuffer;

                dxForm = new Form();   //仅供创建device用,不会在其表面绘图
                dxDevice = new Device(0, DeviceType.Hardware, dxForm,
                    CreateFlags.HardwareVertexProcessing | CreateFlags.MultiThreaded | CreateFlags.FpuPreserve, presentParams); //实例化device对象
                
                dxSurface = dxDevice.GetBackBuffer(0, 0, BackBufferType.Mono);

                return true;
            }
            catch (DirectXException )
            {
                return false;
            }
        }
开发者ID:fjkfjk,项目名称:ExerciseDemo,代码行数:26,代码来源:MainWindow.xaml.cs

示例6: CreateGraphicsDevice3D

        public static bool CreateGraphicsDevice3D(GraphicsDevice3DOutputDescription desc, Control deviceTarget,
                                                  out GraphicsDevice3DOutputDescription outDesc, out Device device,
                                                  out PresentParameters pParams)
        {
            try
            {
                pParams = new PresentParameters();
                if (desc.DepthFormat != DepthFormat.Unknown)
                {
                    pParams.EnableAutoDepthStencil = true;
                    pParams.AutoDepthStencilFormat = desc.DepthFormat;
                }
                if (desc.Format != Format.Unknown)
                    pParams.BackBufferFormat = desc.Format;
                pParams.MultiSample = desc.MultiSample;
                pParams.SwapEffect = SwapEffect.Discard;
                pParams.Windowed = desc.Windowed;

                device = new Device(desc.Adapter, desc.Type, deviceTarget, desc.CreateFlags, pParams);

                // capture actual final output description
                outDesc = new GraphicsDevice3DOutputDescription(desc.Adapter, desc.Windowed,
                                                                device.CreationParameters.DeviceType,
                                                                device.DisplayMode.Format,
                                                                device.GetBackBuffer(0, 0, BackBufferType.Mono).Description.MultiSampleType,
                                                                device.PresentationParameters.AutoDepthStencilFormat,
                                                                desc.CreateFlags);

                return true;
            }
            catch (Exception)
            { }

            pParams = null;
            device = null;
            outDesc = null;
            return false;
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:38,代码来源:GraphicsDeviceManager.cs

示例7: CreateDisplayObjects

        private void CreateDisplayObjects(Device device)
        {
            displaySprite = new Sprite(device);
            bufferedSurface = Surface.CreateRenderTarget(device, 256, scanlines, Format.A8R8G8B8,
                MultisampleType.None, 0, true);

            frontSurface = device.GetBackBuffer(0, 0);
        }
开发者ID:ywjno,项目名称:mynes-code,代码行数:8,代码来源:DirectXVideo.cs

示例8: DirectXInit

        private void DirectXInit()
        {
            try
            {
                SMeter.displayEngine = AnalogGAuge.AGauge.DisplayDriver.DIRECTX;
                DX.MainForm = this;
                SMeter.GaugeTarget = SMeter;
                SMeter.DirectX_Init(Application.StartupPath + "\\SMeter.jpg");

                monitor_target = picMonitor;
                PresentParameters presentParms = new PresentParameters();
                presentParms.Windowed = true;
                presentParms.SwapEffect = SwapEffect.Discard;
                presentParms.BackBufferFormat = SlimDX.Direct3D9.Format.Unknown;
                presentParms.BackBufferHeight = monitor_target.Height;
                presentParms.BackBufferWidth = monitor_target.Width;
                presentParms.BackBufferCount = 1;
                presentParms.BackBufferFormat = Format.X8R8G8B8;

                try
                {
                    if (DX.DirectXRenderType == RenderType.HARDWARE)
                        waterfall_dx_device = new Device(new Direct3D(), 0,
                            DeviceType.Hardware, monitor_target.Handle,
                            CreateFlags.HardwareVertexProcessing | CreateFlags.FpuPreserve |
                             CreateFlags.Multithreaded, presentParms);
                    else
                        waterfall_dx_device = new Device(new Direct3D(), 0,
                            DeviceType.Hardware, monitor_target.Handle,
                            CreateFlags.SoftwareVertexProcessing | CreateFlags.FpuPreserve |
                            CreateFlags.Multithreaded, presentParms);
                }
                catch (Direct3D9Exception ex)
                {
                    MessageBox.Show("DirectX hardware init error!\n" + ex.ToString());

                    try
                    {
                        waterfall_dx_device = new Device(new Direct3D(), 0,
                            DeviceType.Hardware, monitor_target.Handle,
                            CreateFlags.SoftwareVertexProcessing | CreateFlags.FpuPreserve, presentParms);

                    }
                    catch (Direct3D9Exception exe)
                    {
                        MessageBox.Show("DirectX software init error!\n" + exe.ToString());
                    }
                }

                DX.PanadapterTarget = picPanadapter;
                DX.WaterfallTarget = picWaterfall;
                DX.WaterfallInit();
                DX.DirectXInit();

                waterfall_bmp = new System.Drawing.Bitmap(monitor_target.Width, monitor_target.Height,
                    System.Drawing.Imaging.PixelFormat.Format32bppPArgb);

                BitmapData bitmapData = waterfall_bmp.LockBits(
                    new Rectangle(0, 0, waterfall_bmp.Width, waterfall_bmp.Height),
                    ImageLockMode.ReadWrite, waterfall_bmp.PixelFormat);

                waterfall_bmp_size = bitmapData.Stride * waterfall_bmp.Height;
                waterfall_bmp_stride = bitmapData.Stride;
                waterfall_memory = new byte[waterfall_bmp_size];
                waterfall_bmp.UnlockBits(bitmapData);
                waterfall_rect = new Rectangle(0, 0, monitor_target.Width, monitor_target.Height);
                backbuf = waterfall_dx_device.GetBackBuffer(0, 0);

                if (File.Exists(DX.background_image))
                {
                    WaterfallTexture = Texture.FromFile(waterfall_dx_device, DX.background_image, monitor_target.Width, monitor_target.Height,
                        1, Usage.None, Format.X8R8G8B8, Pool.Managed, SlimDX.Direct3D9.Filter.Default, SlimDX.Direct3D9.Filter.Default, 0);
                    Waterfall_texture_size.Width = monitor_target.Width;
                    Waterfall_texture_size.Height = monitor_target.Height;
                    Waterfall_Sprite = new Sprite(waterfall_dx_device);

                    PanadapterTexture = Texture.FromFile(waterfall_dx_device, DX.background_image, monitor_target.Width, monitor_target.Height,
                        1, Usage.None, Format.X8R8G8B8, Pool.Managed, SlimDX.Direct3D9.Filter.Default, SlimDX.Direct3D9.Filter.Default, 0);
                    Panadapter_texture_size.Width = monitor_target.Width;
                    Panadapter_texture_size.Height = monitor_target.Height;
                    Panadapter_Sprite = new Sprite(waterfall_dx_device);
                }
                else
                {
                    Panadapter_Sprite = null;
                    WaterfallTexture = new Texture(waterfall_dx_device, monitor_target.Width, monitor_target.Height, 0,
                        Usage.None, Format.X8R8G8B8, Pool.Managed);
                    Waterfall_texture_size.Width = monitor_target.Width;
                    Waterfall_texture_size.Height = monitor_target.Height;
                    Waterfall_Sprite = new Sprite(waterfall_dx_device);
                }

                var vertexElems = new[] {
                        new VertexElement(0, 0, DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.PositionTransformed, 0),
                        new VertexElement(0, 16, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0),
                        VertexElement.VertexDeclarationEnd
                        };

                var vertexDecl1 = new VertexDeclaration(waterfall_dx_device, vertexElems);
                waterfall_dx_device.VertexDeclaration = vertexDecl1;
//.........这里部分代码省略.........
开发者ID:GoranRadivojevic,项目名称:CW-expert,代码行数:101,代码来源:CWExpert.cs

示例9: SetDevice

        /// <summary>
        /// Passes a previously created Direct3D device for use by the framework.  
        /// If CreateWindow() has not already been called, it will call it with the 
        /// default parameters.  Instead of calling this, you can call CreateDevice() or 
        /// CreateDeviceFromSettings() 
        /// </summary>
        public void SetDevice(Device device)
        {
            if (device == null)
                throw new ArgumentNullException("device", "You cannot pass in a null device to SetDevice");

            if (State.IsInsideDeviceCallback)
                throw new InvalidOperationException("You cannot set a device from inside a callback.");

            // Was the window created? If not, create it now
            if (!State.WasWindowCreated)
            {
                // If CreateWindow or SetWindow was already called and failed, then fail again.
                if (State.WasWindowCreateCalled)
                {
                    throw new InvalidOperationException("CreateWindow was already called and failed.");
                }

                // Create a default window
                CreateWindow("Direct3D Window", null, null, -1, -1);
            }

            DeviceSettings deviceSettings = new DeviceSettings();

            // Get the present parameters from the swap chain
            using(Surface backBuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono))
            {
                using (SwapChain swap = backBuffer.GetContainer(InterfaceGuid.SwapChain) as SwapChain)
                {
                    deviceSettings.presentParams = swap.PresentParameters;
                    System.Diagnostics.Debug.Assert(deviceSettings.presentParams != null, "You must have valid present parameters here.");
                }
            }

            DeviceCreationParameters creationParams = device.CreationParameters;

            // Fill out the device settings structure now
            deviceSettings.AdapterOrdinal = (uint)creationParams.AdapterOrdinal;
            deviceSettings.DeviceType = creationParams.DeviceType;
            deviceSettings.AdapterFormat = FindAdapterFormat(deviceSettings.AdapterOrdinal,
                deviceSettings.DeviceType, deviceSettings.presentParams.BackBufferFormat,
                deviceSettings.presentParams.Windowed);
            deviceSettings.BehaviorFlags = creationParams.Behavior.Value;

            // Change to the Direct3D device passed in
            ChangeDevice(deviceSettings, device, false);
        }
开发者ID:JamesTryand,项目名称:simergy,代码行数:52,代码来源:dxmut.cs

示例10: PrepareDevice

            /// <summary>
            /// Prepares a new or resetting device by with cursor info and
            /// store backbuffer desc and caps from the device
            /// </summary>
            private void PrepareDevice(Device device)
            {
            // Update the device stats text
            UpdateStaticFrameStats();

            // Store render target surface desc
            using(Surface backBuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono))
            {
                State.BackBufferSurfaceDesc = backBuffer.Description;
            }

            // Update the state's copy of caps
            State.Caps = device.DeviceCaps;

            // Setup the full screen cursor
            if (State.IsShowingCursorWhenFullScreen && !IsWindowed)
            {
                // Get a valid cursor
                System.Windows.Forms.Cursor cursor = System.Windows.Forms.Cursor.Current;
                if (cursor == null)
                    cursor = System.Windows.Forms.Cursors.Default;

                device.SetCursor(cursor, false);
                device.ShowCursor(true);
            }

            // Confine cursor to full screen window
            if (State.IsCursorClippedWhenFullScreen)
            {
                if (!IsWindowed)
                {
                    // Turn on clipping for the full screen window
                    System.Windows.Forms.Cursor.Clip = State.FullScreenClientRectangle;
                }
                else
                {
                    // Turn off clipping
                    System.Windows.Forms.Cursor.Clip = System.Drawing.Rectangle.Empty;
                }
            }
            }
开发者ID:JamesTryand,项目名称:simergy,代码行数:45,代码来源:dxmut.cs

示例11: Initialize3DEnvironment

        private void Initialize3DEnvironment()
        {
            DisplayAdapter adapterInfo = graphicsSettings.DisplayAdapter;
            DisplayDevice deviceInfo = graphicsSettings.DisplayDevice;

            isWindowed = graphicsSettings.IsWindowed;

            // Prepare window for possible windowed/fullscreen change
            // AdjustWindowForChange();

            // Set up the presentation parameters
            RefreshPresentParameters();

            if(deviceInfo.Caps.PrimitiveMiscCaps.IsNullReference)
            {
                // Warn user about null ref device that can't render anything
                throw new ApplicationException("null reference device");
            }

            CreateFlags createFlags = new CreateFlags();
            switch(graphicsSettings.VertexProcessingType)
            {
                case VertexProcessingType.Software:
                    createFlags = CreateFlags.SoftwareVertexProcessing;
                    break;
                case VertexProcessingType.Mixed:
                    createFlags = CreateFlags.MixedVertexProcessing;
                    break;
                case VertexProcessingType.Hardware:
                    createFlags = CreateFlags.HardwareVertexProcessing;
                    break;
                case VertexProcessingType.PureHardware:
                    createFlags = CreateFlags.HardwareVertexProcessing | CreateFlags.PureDevice;
                    break;
                default:
                    throw new ApplicationException("Unable to determine vertex processing method.");
            }

            // Create the device
            device = new Device(graphicsSettings.AdapterOrdinal,
                graphicsSettings.DisplayDevice.DeviceType,
                this.viewport,
                createFlags,
                this.presentParameters);

            if( device != null )
            {
                // Cache our local objects
                renderStates = device.RenderState;
                samplerStates = device.SamplerState;
                textureStates = device.TextureState;
                // When moving from fullscreen to windowed mode, it is important to
                // adjust the window size after recreating the device rather than
                // beforehand to ensure that you get the window size you want.  For
                // example, when switching from 640x480 fullscreen to windowed with
                // a 1000x600 window on a 1024x768 desktop, it is impossible to set
                // the window size to 1000x600 until after the display mode has
                // changed to 1024x768, because windows cannot be larger than the
                // desktop.
                if(graphicsSettings.IsWindowed && (this.viewport is System.Windows.Forms.Form))
                {
                    // Make sure main window isn't topmost, so error message is visible
                    this.viewport.Location = new System.Drawing.Point(rectWindowBounds.Left, rectWindowBounds.Top);
                    this.viewport.Size = new System.Drawing.Size(( rectWindowBounds.Right - rectWindowBounds.Left ), ( rectWindowBounds.Bottom - rectWindowBounds.Top));
                }

                // Store device Caps
                graphicsCaps = device.DeviceCaps;
                behavior = createFlags;

                // Store render target surface desc
                Surface BackBuffer = device.GetBackBuffer(0,0, BackBufferType.Mono);
                backBufferDesc = BackBuffer.Description;
                BackBuffer.Dispose();
                BackBuffer = null;

                // Set up the fullscreen cursor
                if(showFullScreenCursor && !graphicsSettings.IsWindowed)
                {
                    System.Windows.Forms.Cursor ourCursor = this.viewport.Cursor;
                    device.SetCursor(ourCursor, true);
                    device.ShowCursor(true);
                }

                // Confine cursor to fullscreen window
                if(clipFullScreenCursor)
                {
                    if (!isWindowed)
                    {
                        System.Drawing.Rectangle rcWindow = this.viewport.ClientRectangle;
                    }
                }

                // Setup the event handlers for our device
                device.DeviceLost += InvalidateDeviceObjects;
                device.DeviceReset += RestoreDeviceObjects;
                device.Disposing += DeleteDeviceObjects;
                device.DeviceResizing += new CancelEventHandler(EnvironmentResized);

                // Initialize the app's device-dependent objects
//.........这里部分代码省略.........
开发者ID:deobald,项目名称:midget,代码行数:101,代码来源:Direct3DHost.cs

示例12: MainWindow

        /// <summary>
        /// 最上位ウインドウを作成
        /// </summary>
        public MainWindow()
        {
            // コンポーネント初期化
            InitializeComponent();

            // デバイスを作成
            Device device = new Device(
                new Direct3D(),
                0,
                DeviceType.Hardware,
                IntPtr.Zero,
                CreateFlags.HardwareVertexProcessing,
                new PresentParameters());

            // 光源を設定して有効化
            device.SetLight(0, new Light()
            {
                Type = LightType.Directional,
                Diffuse = Color.White,
                Ambient = Color.GhostWhite,
                Direction = new Vector3(0, -1, 1)
            });
            device.EnableLight(0, true);

            //射影変換を設定
            device.SetTransform(TransformState.Projection,
                Matrix.PerspectiveFovLH((float)(Math.PI / 4),
                (float)(this.Width / this.Height),
                0.1f, 20.0f));

            //ビューを設定
            device.SetTransform(TransformState.View,
                Matrix.LookAtLH(new Vector3(3, 2, -3),
                Vector3.Zero,
                new Vector3(0, 1, 0)));

            //マテリアル設定
            device.Material = new Material()
            {
                Diffuse = new Color4(Color.GhostWhite)
            };

            // 全面灰色でクリア
            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, new Color4(0.2f, 0.2f, 0.2f), 1.0f, 0);

            // シーン開始
            device.BeginScene();

            //ティーポットを描画
            device.SetTransform(TransformState.World,
                Matrix.Translation(-3, 0, 5));
            Mesh.CreateTeapot(device).DrawSubset(0);

            //文字列を描画
            device.SetTransform(TransformState.World,
                Matrix.Translation(-4, -1, 0));
            Mesh.CreateText(device, new System.Drawing.Font("Arial", 10), "Hello, world!", 0.001f, 0.001f).DrawSubset(0);

            // シーン終了
            device.EndScene();

            // 画像をロック
            this.directXImage.Lock();

            // バックバッファー領域を指定
            this.directXImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, device.GetBackBuffer(0, 0).ComPointer);
            this.directXImage.AddDirtyRect(new Int32Rect(0, 0, directXImage.PixelWidth, directXImage.PixelHeight));

            // ロック解除
            this.directXImage.Unlock();
        }
开发者ID:aokomoriuta,项目名称:StudiesOfSlimDX,代码行数:74,代码来源:MainWindow.cs

示例13: CreateDevice

        public void CreateDevice()
        {
            DestroyDevice();

            var pp = MakePresentParameters();

            var flags = CreateFlags.SoftwareVertexProcessing;
            if ((d3d.GetDeviceCaps(0, DeviceType.Hardware).DeviceCaps & DeviceCaps.HWTransformAndLight) != 0)
            {
                flags = CreateFlags.HardwareVertexProcessing;
            }

            flags |= CreateFlags.FpuPreserve;
            dev = new Device(d3d, 0, DeviceType.Hardware, pp.DeviceWindowHandle, flags, pp);
            devBB = dev.GetBackBuffer(0, 0);
        }
开发者ID:CadeLaRen,项目名称:BizHawk,代码行数:16,代码来源:IGL_SlimDX9.cs

示例14: MainWindow

        /// <summary>
        /// 最上位ウインドウを作成
        /// </summary>
        public MainWindow()
        {
            // コンポーネント初期化
            InitializeComponent();

            // ウインドウが読み込まれたら
            this.Loaded += (sender, e) =>
            {
                // Direct3D作成
                var direct3D = new SlimDX.Direct3D9.Direct3D();

                // デバイスを初期化
                Device device = null;

                // ティーポッドと文字列を初期化
                Mesh teapod = null;
                Mesh helloWorld = null;

                // バッファーウインドウ作成
                IntPtr handle = new HwndSource(0, 0, 0, 0, 0, "buffer", IntPtr.Zero).Handle;

                // デバイスを作成
                device = new Device(direct3D, 0,
                    DeviceType.Hardware,
                    handle,
                    CreateFlags.HardwareVertexProcessing,
                    new PresentParameters()
                    {
                        BackBufferFormat = Format.X8R8G8B8,
                        BackBufferCount = 1,
                        BackBufferWidth = (int)this.Width,
                        BackBufferHeight = (int)this.Height,
                        Multisample = MultisampleType.None,
                        SwapEffect = SwapEffect.Discard,
                        EnableAutoDepthStencil = true,
                        AutoDepthStencilFormat = Format.D16,
                        PresentFlags = PresentFlags.DiscardDepthStencil,
                        PresentationInterval = PresentInterval.Default,
                        Windowed = true,
                        DeviceWindowHandle = handle
                    });

                // ティーポッドと文字列を作成
                teapod = Mesh.CreateTeapot(device);
                helloWorld = Mesh.CreateText(device, new System.Drawing.Font("Arial", 10), "Hello, world!", 0.001f, 0.001f);

                // 光源描画を有効化
                device.SetRenderState(RenderState.Lighting, true);

                // 光源を設定
                device.SetLight(0, new Light()
                {
                    Type = LightType.Directional,
                    Diffuse = Color.White,
                    Ambient = Color.GhostWhite,
                    Direction = new Vector3(0.0f, -1.0f, 0.0f)
                });

                // 光源を有効化
                device.EnableLight(0, true);

                //射影変換を設定
                device.SetTransform(TransformState.Projection,
                    Matrix.PerspectiveFovLH((float)(Math.PI / 4),
                    (float)(this.Width / this.Height),
                    0.1f, 20.0f));

                //ビューを設定
                device.SetTransform(TransformState.View,
                    Matrix.LookAtLH(new Vector3(3.0f, 2.0f, -3.0f),
                    Vector3.Zero,
                    new Vector3(0.0f, 1.0f, 0.0f)));

                //マテリアル設定
                device.Material = new Material()
                {
                    Diffuse = new Color4(Color.GhostWhite)
                };

                // 描画される時に描画処理を実行
                CompositionTarget.Rendering += (sender2, e2) =>
                {
                    // 画像をロックしてバックバッファーに設定
                    this.directXImage.Lock();
                    this.directXImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, device.GetBackBuffer(0, 0).ComPointer);

                    // フロントバッファーがあれば
                    if (directXImage.IsFrontBufferAvailable)
                    {
                        // デバイスの現在の状態を確かめて失敗したら
                        if (device.TestCooperativeLevel().IsFailure)
                        {
                            // 例外
                            throw new Direct3D9Exception("デバイスが無効です");
                        }

                        // 全面灰色でクリア
//.........这里部分代码省略.........
开发者ID:aokomoriuta,项目名称:StudiesOfOpenTK,代码行数:101,代码来源:MainWindow.cs

示例15: Screenshot

        public void Screenshot(Device device, string filename, int primCount, int numVertices)
        {
            Surface surf;
            using (Surface backbuffer = device.GetBackBuffer(0, 0))
            {
                using (SwapChain sc = device.GetSwapChain(0))
                {
                    surf = Surface.CreateOffscreenPlain(device, sc.PresentParameters.BackBufferWidth, sc.PresentParameters.BackBufferHeight, sc.PresentParameters.BackBufferFormat, Pool.SystemMemory);
                }
                try
                {
                    device.GetRenderTargetData(backbuffer, surf);
                    if(!Directory.Exists(filename + "Output"))
                        Directory.CreateDirectory(filename + "Output");

                    if (!Directory.Exists(filename + "Output\\"+ Interface.exe))
                        Directory.CreateDirectory(filename + "Output\\" + Interface.exe);

                    Surface.ToFile(surf, filename + "Output\\" + Interface.exe + "\\" + primCount + "x" + numVertices + ".bmp", ImageFileFormat.Bmp);
                    surf.Dispose();
                }
                catch (Exception e)
                {
                    Interface.ReportException(e);
                }
            }
        }
开发者ID:emist,项目名称:D3DTextureLoggerClient,代码行数:27,代码来源:Main.cs


注:本文中的Device.GetBackBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。