packages/Windows API Code Pack 1.1/source/Samples/DirectX/CS/Direct3D10/Tutorials/D3D10Tutorial06_WinFormsControl/TutorialWindow.cs
/// <summary>
/// Create Direct3D device and swap chain
/// </summary>
Create Direct3D device and swap chain
Create Direct3D device and swap chain
protected void InitDevice()
        {
            device = D3DDevice.CreateDeviceAndSwapChain(directControl.Handle);
            swapChain = device.SwapChain;
            SetViews();
            using (FileStream effectStream = File.OpenRead("Tutorial06.fxo"))
            {
                effect = device.CreateEffectFromCompiledBinary(new BinaryReader(effectStream));
            }
            technique = effect.GetTechniqueByName("Render");
            techniqueLight = effect.GetTechniqueByName("RenderLight");
            worldVariable = effect.GetVariableByName("World").AsMatrix;
            viewVariable = effect.GetVariableByName("View").AsMatrix;
            projectionVariable = effect.GetVariableByName("Projection").AsMatrix;
            lightDirVariable = effect.GetVariableByName("vLightDir").AsVector;
            lightColorVariable = effect.GetVariableByName("vLightColor").AsVector;
            outputColorVariable = effect.GetVariableByName("vOutputColor").AsVector;
            InitVertexLayout();
            InitVertexBuffer();
            InitIndexBuffer();
            device.IA.PrimitiveTopology = PrimitiveTopology.TriangleList;
            InitMatrices();
        }
protected void InitDevice ( ) { device = D3DDevice . CreateDeviceAndSwapChain ( directControl . Handle ) ; swapChain = device . SwapChain ; SetViews ( ) ; using ( FileStream effectStream = File . OpenRead ( " " ) ) { effect = device . CreateEffectFromCompiledBinary ( new BinaryReader ( effectStream ) ) ; } technique = effect . GetTechniqueByName ( " " ) ; techniqueLight = effect . GetTechniqueByName ( " " ) ; worldVariable = effect . GetVariableByName ( " " ) . AsMatrix ; viewVariable = effect . GetVariableByName ( " " ) . AsMatrix ; projectionVariable = effect . GetVariableByName ( " " ) . AsMatrix ; lightDirVariable = effect . GetVariableByName ( " " ) . AsVector ; lightColorVariable = effect . GetVariableByName ( " " ) . AsVector ; outputColorVariable = effect . GetVariableByName ( " " ) . AsVector ; InitVertexLayout ( ) ; InitVertexBuffer ( ) ; InitIndexBuffer ( ) ; device . IA . PrimitiveTopology = PrimitiveTopology . TriangleList ; InitMatrices ( ) ; }
Create Direct3D device and swap chain
Create Direct3D device and swap chain
// Create the effect // Obtain the technique // Obtain the variables // Set primitive topology