0% found this document useful (0 votes)
52 views3 pages

13 Sept Practical No 1

This document provides steps to set up a DirectX 11 window framework and initialize a Direct3D device in C#. It involves creating a Windows Forms application, adding DirectX references, initializing the device in code, and handling the Form's Paint event to call a Render method and present the device. The output is a window with an orange background, demonstrating the initialization of the 3D device.

Uploaded by

Zill Pill
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views3 pages

13 Sept Practical No 1

This document provides steps to set up a DirectX 11 window framework and initialize a Direct3D device in C#. It involves creating a Windows Forms application, adding DirectX references, initializing the device in code, and handling the Form's Paint event to call a Render method and present the device. The output is a window with an orange background, demonstrating the initialization of the 3D device.

Uploaded by

Zill Pill
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Practical No.

1:
Aim: Setup DirectX 11, Window Framework and Initialize Direct3D Device
In this practical we are just learning the window framework and initializing a Direct3D device.
Step 1:
i) Create new project, and select “Windows Forms Application”, select .NET
Framework as 2.0 in Visuals C#.
ii) Right Click on properties Click on open click on build Select Platform Target and
Select x86.
Step 2: Click on View Code of Form 1.
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”.
Step 4:
Go to the Properties Section of Form, select Paint in the Event List and enter as
Form1_Paint.
Step 5:
Edit the Form’s C# code file. Namespace must be the same as your project name.
using System;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
usingMicrosoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace GP_P1
{
public partial class Form1 : Form
{
Microsoft.DirectX.Direct3D.Device device;
public Form1()
{
InitializeComponent();
InitDevice();
}

public void InitDevice()


{
PresentParameters pp = new PresentParameters();
pp.Windowed = true;
pp.SwapEffect = SwapEffect.Discard;
device = new Device(0, DeviceType.Hardware, this,
CreateFlags.HardwareVertexProcessing, pp);
}

private void Render()


{
device.Clear(ClearFlags.Target, Color.Orange, 0, 1);
device.Present();
}

private void Form1_Paint(object sender, PaintEventArgs e)


{
Render();
}
}
}

Step 6: Click on Start. And here is the output. We have initialized 3D Device.

Output:

You might also like