, Visual C#


- 5


myPresentParameters.EnableAutoDepthStencil = true;

myPresentParameters.AutoDepthStencilFormat =

DepthFormat.D16;

// :

myDevice = new Device(0, DeviceType.Hardware, this,

CreateFlags.SoftwareVertexProcessing,

myPresentParameters);

myDevice.DeviceReset +=

new System.EventHandler(this.OnResetDevice);

this.OnCreateDevice(myDevice, null);

this.OnResetDevice(myDevice, null);

myPause = false;

return true;

}

catch (DirectXException)

{

// DirectX:

return false;

}

}

// :

public void OnCreateDevice(object sender, EventArgs e)

{

Device myDev = (Device)sender;

myVertexBuffer = new VertexBuffer(

typeof(CustomVertex.PositionNormalTextured), 100,

myDev, Usage.WriteOnly,

CustomVertex.PositionNormalTextured.Format,

Pool.Default);

myVertexBuffer.Created +=

new System.EventHandler(this.OnCreateVertexBuffer);

this.OnCreateVertexBuffer(myVertexBuffer, null);

}

// :

public void OnResetDevice(object sender, EventArgs e)

{

Device myDev = (Device)sender;

// CullMode,

// :

myDev.RenderState.CullMode = Cull.None;

// :

myDev.RenderState.Lighting = false;

// Z - (ZBuffer):

myDev.RenderState.ZBufferEnable = true;

// .

// Texture_1

// :

myTexture = TextureLoader.FromFile(myDev,

Application.StartupPath + @"\..\..\Texture_1.bmp");

}

// :

public void OnCreateVertexBuffer(object sender, EventArgs e)

{

VertexBuffer myVB = (VertexBuffer)sender;

// PositionNormalTextured