nikkkilll

khel1

Oct 4th, 2019
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. Practical 1:
  2. AIM: Setup DirectX 11, Window Framework And Initialize Direct3D Device.
  3. Step 1:Create new project, and select “Windows Forms Application”, select .NET Framework as 2.0 in Visuals C#.Click on properties Click on open click on build Select Platform Target and Select x86.
  4.  
  5. Step 2:Click on View Code of Form 1.
  6.  
  7. Step 3:Go to Solution Explorer, right click on project name, and select Add Reference. Click on Browse and select the given .dll files which are “Microsoft.DirectX”, “Microsoft.DirectX.Direct3D”, and “Microsoft.DirectX.DirectX3DX”.
  8.  
  9. Step 4:Go to Properties Section of Form, select Paint in the Event List and enter as Form1_Paint.
  10.  
  11. Step 5:Copy and Paste the below given code into Form’s C# code file. Namespace must be as same as your project name.
  12.  
  13. Program
  14.  
  15. using System;
  16. using System.Collections.Generic;
  17. using System.ComponentModel;
  18. using System.Data;
  19. using System.Drawing;
  20. using System.Text;
  21. using System.Windows.Forms;
  22. using Microsoft.DirectX;
  23. using Microsoft.DirectX.Direct3D;
  24.  
  25.  
  26. namespace WindowsFormsApplication1
  27. {
  28. public partial class Form1 : Form
  29. {
  30. Microsoft.DirectX.Direct3D.Device device;
  31. public Form1()
  32. {
  33.  
  34. InitializeComponent();
  35. InitDevice();
  36.  
  37. }
  38. public void InitDevice()
  39. {
  40. PresentParameters pp = new PresentParameters(); pp.Windowed = true;
  41. pp.SwapEffect = SwapEffect.Discard;
  42.  
  43. device = new Device(0, DeviceType.Hardware, this, CreateFlags.HardwareVertexProcessing, pp);
  44. }
  45. private void Render()
  46. {
  47. device.Clear(ClearFlags.Target, Color.DarkOliveGreen, 0, 1); device.Present();
  48.  
  49. }
  50.  
  51.  
  52. private void Form1_Paint(object sender, PaintEventArgs e)
  53. {
  54. Render();
  55. }
  56. }
  57. }
Add Comment
Please, Sign In to add comment