Программирование - это просто
Advertisement
arrow C# arrow C# arrow C#. 3. DirectX
06.02.2023 .
1:
C#
Delphi
Web-
Excel-
.
C#. 3. DirectX E-mail
megabax   
10.09.2011 .
New Page 2

C#. 3. DirectX

2 . DirectX, . , , , . Visual Studio , . , Microsoft http://www.microsoft.com/windows/directX/downloads. Microsoft.DirectX Microsoft.DirectX.Direct3D - ".NET". , "" "C:\Windows\Microsoft.NET\DirectX for Managed Code\1.0.2902.0" ( , , , ""C:\Windows\"), Microsoft.DirectX.dll Microsoft.DirectX.Direct3D.dll. :

    C#.  3.   DirectX

: . "", :

    C#.  3.   DirectX

, . DirectX ( using). initializeDirectX() rendering(), ESC . ( , , , ):

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;  

using System.Text;

using System.Windows.Forms;

using Microsoft.DirectX;

using Microsoft.DirectX.Direct3D;

 

namespace DX

{

    public partial class FormChild : Form

    {

        private Device device=null;

        public FormChild()

        {

            InitializeComponent();

        }

 

        public bool initializeDirectX()

        {

            try

            {

                PresentParameters presPars = new PresentParameters();

                presPars.Windowed = true;

                presPars.SwapEffect = SwapEffect.Discard;

                device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presPars);

                return true;

            }

            catch (DirectXException e)

            {

                MessageBox.Show(" DirectX "+e.ErrorString);

                return false;

            }

        }

 

        public void rendering()

        {

            if (device == null) return;

 

            // ()

            device.Clear(ClearFlags.Target, System.Drawing.Color.White, 1.0f, 0);

 

            //

            device.BeginScene();

            device.EndScene();

            device.Present();

        }

 

        private void FormChild_KeyPress(object sender, KeyPressEventArgs e)

        {

            if ((int)(byte)e.KeyChar == (int)System.Windows.Forms.Keys.Escape) this.Close();

        }

     }

}

, :

        private void btnNew_Click(object sender, EventArgs e)

        {

            FormChild form = new FormChild();

            if (!form.initializeDirectX()) return;

            form.Show();

            while (form.Created)

            {

                form.rendering();

                Application.DoEvents();

            }

        }

:

    C#.  3.   DirectX


, ,    "Microsoft Visual Studio 2010", Microsoft


 

 

( 06.11.2011 . )
 
« .   . »
 
© 2023 Программирование - это просто
Joomla! - , GNU/GPL.
© 2005-2008 Joom.Ru - Joomla!
Design by Mamboteam.com | Powered by Mambobanner.de
  .