2. Dodajte ovaj kod u public partial class Form1 : Form
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace MyDirectX
{
public partial class Form1 : Form
{
public Form1 ()
{
InitializeComponent ();
}
private Device device = null;
public void InitializeGraphics ()
{
PresentParameters presentParams = new PresentParameters ();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
device = new Device ( 0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams );
}
protected override void OnPaint ( System.Windows.Forms.PaintEventArgs e )
{
device.Clear ( ClearFlags.Target, System.Drawing.Color.CornflowerBlue, 1.0f, 0 );
device.Present ();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace MyDirectX
{
public partial class Form1 : Form
{
public Form1 ()
{
InitializeComponent ();
}
private Device device = null;
public void InitializeGraphics ()
{
PresentParameters presentParams = new PresentParameters ();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
device = new Device ( 0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams );
}
protected override void OnPaint ( System.Windows.Forms.PaintEventArgs e )
{
device.Clear ( ClearFlags.Target, System.Drawing.Color.CornflowerBlue, 1.0f, 0 );
device.Present ();
}
}
}
a ovaj kod umijesto default Main-a
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace MyDirectX
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main ()
{
using ( Form1 frm = new Form1 () )
{
// Show our form and initialize our graphics engine
frm.Show ();
frm.InitializeGraphics ();
Application.Run ( frm );
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace MyDirectX
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main ()
{
using ( Form1 frm = new Form1 () )
{
// Show our form and initialize our graphics engine
frm.Show ();
frm.InitializeGraphics ();
Application.Run ( frm );
}
}
}
}
Dobije se plava forma.
3. Resize-ajte formu do minimuma i...dobije se pismo