packages/Windows API Code Pack 1.1/source/Samples/DirectX/CS/Direct3D10/Tutorials/D3D10Tutorial07_WPF/TutorialWindow.xaml.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 = D3DDevice1.CreateDeviceAndSwapChain1(host.Handle);
            swapChain = device.SwapChain;
            SetViews();
            using (FileStream effectStream = File.OpenRead("Tutorial07.fxo"))
            {
                effect = device.CreateEffectFromCompiledBinary(new BinaryReader(effectStream));
            }
            technique = effect.GetTechniqueByName("Render");
            worldVariable = effect.GetVariableByName("World").AsMatrix;
            viewVariable = effect.GetVariableByName("View").AsMatrix;
            projectionVariable = effect.GetVariableByName("Projection").AsMatrix;
            meshColorVariable = effect.GetVariableByName("vMeshColor").AsVector;
            diffuseVariable = effect.GetVariableByName("txDiffuse").AsShaderResource;
            InitVertexLayout();
            InitVertexBuffer();
            InitIndexBuffer();
            device.IA.PrimitiveTopology = PrimitiveTopology.TriangleList;
            using (FileStream stream = File.OpenRead("seafloor.png"))
            {
                textureRV = TextureLoader.LoadTexture(device, stream);
            }
            InitMatrices();
            diffuseVariable.Resource = textureRV;
            needsResizing = false;
        }
protected void InitDevice ( ) { device = D3DDevice1 . CreateDeviceAndSwapChain1 ( host . Handle ) ; swapChain = device . SwapChain ; SetViews ( ) ; using ( FileStream effectStream = File . OpenRead ( " " ) ) { effect = device . CreateEffectFromCompiledBinary ( new BinaryReader ( effectStream ) ) ; } technique = effect . GetTechniqueByName ( " " ) ; worldVariable = effect . GetVariableByName ( " " ) . AsMatrix ; viewVariable = effect . GetVariableByName ( " " ) . AsMatrix ; projectionVariable = effect . GetVariableByName ( " " ) . AsMatrix ; meshColorVariable = effect . GetVariableByName ( " " ) . AsVector ; diffuseVariable = effect . GetVariableByName ( " " ) . AsShaderResource ; InitVertexLayout ( ) ; InitVertexBuffer ( ) ; InitIndexBuffer ( ) ; device . IA . PrimitiveTopology = PrimitiveTopology . TriangleList ; using ( FileStream stream = File . OpenRead ( " " ) ) { textureRV = TextureLoader . LoadTexture ( device , stream ) ; } InitMatrices ( ) ; diffuseVariable . Resource = textureRV ; needsResizing = false ; }
Create Direct3D device and swap chain
Create Direct3D device and swap chain
// Create the effect // Obtain the technique // Obtain the variables // Set primitive topology // Load the Texture