当前位置: 首页>>代码示例>>C#>>正文


C# Device.Init方法代码示例

本文整理汇总了C#中Device.Init方法的典型用法代码示例。如果您正苦于以下问题:C# Device.Init方法的具体用法?C# Device.Init怎么用?C# Device.Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Device的用法示例。


在下文中一共展示了Device.Init方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ViewerForm

        //        Primitive						m_Prim_Cube;
        public ViewerForm( BImage _Image )
        {
            InitializeComponent();

            //TransparencyKey = SystemColors.Control;

            // Setup device
            m_Device = new Device();
            m_Device.Init( Handle, false, true );

            m_CB_Global = new ConstantBuffer< CB_Global >( m_Device, 0 );

            // Create shaders
            m_Shader_Render2D = new Shader( m_Device, new ShaderFile( new System.IO.FileInfo( @"./Shaders/Render2D.hlsl" ) ), VERTEX_FORMAT.Pt4, "VS", null, "PS", null );

            // Create the texture
            try
            {
                if ( _Image.m_Opts.m_type == BImage.ImageOptions.TYPE.TT_2D ) {
                    m_Tex2D = _Image.CreateTexture2D( m_Device );

                    m_CB_Global.m.m_ImageWidth = (uint) m_Tex2D.Width;
                    m_CB_Global.m.m_ImageHeight = (uint) m_Tex2D.Height;
                    m_CB_Global.m.m_ImageDepth = (uint) m_Tex2D.ArraySize;
                    m_CB_Global.m.m_ImageType = 0;

                    integerTrackbarControlMipLevel.RangeMax = m_Tex2D.MipLevelsCount;
                    integerTrackbarControlMipLevel.VisibleRangeMax = m_Tex2D.MipLevelsCount;

                } else if ( _Image.m_Opts.m_type == BImage.ImageOptions.TYPE.TT_CUBIC ) {
                    m_TexCube = _Image.CreateTextureCube( m_Device );

                    m_CB_Global.m.m_ImageWidth = (uint) m_TexCube.Width;
                    m_CB_Global.m.m_ImageHeight = (uint) m_TexCube.Height;
                    m_CB_Global.m.m_ImageDepth = (uint) m_TexCube.ArraySize;
                    m_CB_Global.m.m_ImageType = 1;

                    integerTrackbarControlMipLevel.RangeMax = m_TexCube.MipLevelsCount;
                    integerTrackbarControlMipLevel.VisibleRangeMax = m_TexCube.MipLevelsCount;

                } else if ( _Image.m_Opts.m_type == BImage.ImageOptions.TYPE.TT_3D ) {
                    m_Tex3D = _Image.CreateTexture3D( m_Device );
                }

                // Enable EV manipulation for HDR images
                bool	showExposure = _Image.m_Opts.m_format.m_type == BImage.PixelFormat.Type.FLOAT;
                labelEV.Visible = showExposure;
                floatTrackbarControlEV.Visible = showExposure;

            }
            catch ( Exception _e )
            {
                MessageBox.Show( this, "Failed to create a valid texture from the image:\r\n\r\n" + _e.Message, "BImage Viewer", MessageBoxButtons.OK, MessageBoxIcon.Error );
            }

            Application.Idle += new EventHandler( Application_Idle );
        }
开发者ID:Patapom,项目名称:GodComplex,代码行数:58,代码来源:ViewerForm.cs

示例2: Form1

        public Form1()
        {
            InitializeComponent();

            m_Device = new Device();
            m_Device.Init( panel1.Handle, false, false );

            m_Shader_RenderCellPlanes = new Shader( m_Device, new ShaderFile( new System.IO.FileInfo( "RenderCellPlanes.hlsl" ) ), VERTEX_FORMAT.T2, "VS", null, "PS", null );
            m_Shader_RenderCellMesh = new Shader( m_Device, new ShaderFile( new System.IO.FileInfo( "RenderCellMesh.hlsl" ) ), VERTEX_FORMAT.P3N3, "VS", null, "PS", null );
            m_Shader_RenderCellMesh_Opaque = new Shader( m_Device, new ShaderFile( new System.IO.FileInfo( "RenderCellMesh_Opaque.hlsl" ) ), VERTEX_FORMAT.P3N3, "VS", null, "PS", null );
            m_Shader_PostProcess = new Shader( m_Device, new ShaderFile( new System.IO.FileInfo( "PostProcess.hlsl" ) ), VERTEX_FORMAT.Pt4, "VS", null, "PS", null );
            m_Shader_PostProcess2 = new Shader( m_Device, new ShaderFile( new System.IO.FileInfo( "PostProcess.hlsl" ) ), VERTEX_FORMAT.Pt4, "VS", null, "PS", null );

            VertexT2[]	Vertices = new VertexT2[4] {
                new VertexT2() { UV = new float2( 0, 0 ) },
                new VertexT2() { UV = new float2( 0, 1 ) },
                new VertexT2() { UV = new float2( 1, 0 ) },
                new VertexT2() { UV = new float2( 1, 1 ) },
            };
            m_Prim_Quad = new Primitive( m_Device, 4, VertexT2.FromArray( Vertices ), null, Primitive.TOPOLOGY.TRIANGLE_STRIP, VERTEX_FORMAT.T2 );

            m_RT_WorldPositions[0] = new Texture2D( m_Device, panel1.Width, panel1.Height, 1, 1, PIXEL_FORMAT.RGBA32_FLOAT, false, false, null );
            m_RT_WorldPositions[1] = new Texture2D( m_Device, panel1.Width, panel1.Height, 1, 1, PIXEL_FORMAT.RGBA32_FLOAT, false, false, null );
            m_Device.Clear( m_RT_WorldPositions[0], float4.Zero );
            m_Device.Clear( m_RT_WorldPositions[1], float4.Zero );

            // Setup camera
            m_CB_Camera = new ConstantBuffer< CB_Camera >( m_Device, 0 );
            m_CB_Mesh = new ConstantBuffer< CB_Mesh >( m_Device, 1 );

            m_Camera.CreatePerspectiveCamera( 120.0f * (float) Math.PI / 180.0f, (float) panel1.Width / panel1.Height, 0.01f, 100.0f );
            m_Camera.CameraTransformChanged += new EventHandler( Camera_CameraTransformChanged );

            m_CameraManipulator.Attach( panel1, m_Camera );
            m_CameraManipulator.InitializeCamera( -0.1f * float3.UnitZ, float3.Zero, float3.UnitY );

            // Initalize random neighbors
            integerTrackbarControlNeighborsCount_ValueChanged( integerTrackbarControlNeighborsCount, 0 );

            Application.Idle += new EventHandler( Application_Idle );
        }
开发者ID:Patapom,项目名称:GodComplex,代码行数:41,代码来源:Form1.cs

示例3: TryToInitRshPort

 private void TryToInitRshPort(Device device, RshInitPort port)
 {
     var st = device.Init(port);
     if (st != RSH_API.SUCCESS)
         throw new IOException("RSH_API: " + st.ToString() + " :: " + "device.Init(port)");
 }
开发者ID:teodorro,项目名称:Centipede,代码行数:6,代码来源:Connection.cs

示例4: TryToInitRshMemory

 private void TryToInitRshMemory(Device device, RshInitMemory memory)
 {
     var st = device.Init(memory);
     rshMem = memory;
     if (st != RSH_API.SUCCESS)
         throw new IOException("RSH_API: " + st.ToString() + " :: " + "device.Init(memory)");
 }
开发者ID:teodorro,项目名称:Centipede,代码行数:7,代码来源:Connection.cs

示例5: OnLoad

        protected override void OnLoad( EventArgs e )
        {
            base.OnLoad( e );

            try {
                // Initialize the device
                m_device = new Device();
                m_device.Init( graphPanel.Handle, false, true );

                // Create the render shaders
                try {
                    Shader.WarningAsError = false;

                    m_shader_RenderSphere = new Shader( m_device, new System.IO.FileInfo( @"./Shaders/RenderSphere.hlsl" ), VERTEX_FORMAT.Pt4, "VS", null, "PS", null );
                    m_shader_RenderScene = new Shader( m_device, new System.IO.FileInfo( @"./Shaders/RenderScene.hlsl" ), VERTEX_FORMAT.Pt4, "VS", null, "PS", null );
                    m_shader_RenderLDR = new Shader( m_device, new System.IO.FileInfo( @"./Shaders/RenderLDR.hlsl" ), VERTEX_FORMAT.Pt4, "VS", null, "PS", null );
                } catch ( Exception _e ) {
                    throw new Exception( "Failed to compile shader! " + _e.Message );
                }

                // Create CB
                m_CB_Render = new ConstantBuffer< CB_Main >( m_device, 0 );

                // Create textures
                LoadHDRImage();

                m_Tex_HDRBuffer = new Texture2D( m_device, (uint) graphPanel.Width, (uint) graphPanel.Height, 2, 1, PIXEL_FORMAT.RGBA32_FLOAT, false, false, null );

                {	// Build noise texture
                    SimpleRNG.SetSeed( 1U );
                    PixelsBuffer	content = new PixelsBuffer( 256*256*16 );
                    using ( System.IO.BinaryWriter W = content.OpenStreamWrite() )
                        for ( int i=0; i < 256*256; i++ ) {
                            W.Write( (float) SimpleRNG.GetUniform() );
                            W.Write( (float) SimpleRNG.GetUniform() );
                            W.Write( (float) SimpleRNG.GetUniform() );
                            W.Write( (float) SimpleRNG.GetUniform() );
                        }
                    m_Tex_Noise = new Texture2D( m_device, 256, 256, 1, 1, PIXEL_FORMAT.RGBA32_FLOAT, false, false, new PixelsBuffer[] { content } );
                }

                // Build SH coeffs
                const int	ORDERS = 20;
                {
                    const int	TABLE_SIZE = 64;

                    // Load A coeffs into a texture array
                    float[,,]	A = new float[TABLE_SIZE,TABLE_SIZE,ORDERS];
            //					using ( System.IO.FileStream S = new System.IO.FileInfo( @"ConeTable_cosAO_order20.float" ).OpenRead() )
                    using ( System.IO.FileStream S = new System.IO.FileInfo( @"ConeTable_cosTheta_order20.float" ).OpenRead() )
                        using ( System.IO.BinaryReader R = new System.IO.BinaryReader( S ) ) {
                            for ( int thetaIndex=0; thetaIndex < TABLE_SIZE; thetaIndex++ )
                                for ( int AOIndex=0; AOIndex < TABLE_SIZE; AOIndex++ ) {
                                    for ( int order=0; order < ORDERS; order++ )
                                        A[thetaIndex,AOIndex,order] = R.ReadSingle();
                                }
                        }

                    PixelsBuffer[]	coeffSlices = new PixelsBuffer[5];	// 5 slices of 4 coeffs each to get our 20 orders
                    for ( int sliceIndex=0; sliceIndex < coeffSlices.Length; sliceIndex++ ) {
                        PixelsBuffer	coeffSlice = new PixelsBuffer( TABLE_SIZE*TABLE_SIZE*16 );
                        coeffSlices[sliceIndex] = coeffSlice;

                        using ( System.IO.BinaryWriter W = coeffSlice.OpenStreamWrite() ) {
                            for ( int thetaIndex=0; thetaIndex < TABLE_SIZE; thetaIndex++ )
                                for ( int AOIndex=0; AOIndex < TABLE_SIZE; AOIndex++ ) {
                                    W.Write( A[thetaIndex,AOIndex,4*sliceIndex+0] );
                                    W.Write( A[thetaIndex,AOIndex,4*sliceIndex+1] );
                                    W.Write( A[thetaIndex,AOIndex,4*sliceIndex+2] );
                                    W.Write( A[thetaIndex,AOIndex,4*sliceIndex+3] );
                                }
                        }
                    }

                    m_Tex_ACoeffs = new Texture2D( m_device, 64, 64, coeffSlices.Length, 1, PIXEL_FORMAT.RGBA32_FLOAT, false, false, coeffSlices );
                }

                {
                    // Load environment coeffs into a constant buffer
                    float3[]	coeffs = new float3[ORDERS*ORDERS];
                    using ( System.IO.FileStream S = new System.IO.FileInfo( @"Ennis_order20.float3" ).OpenRead() )
                        using ( System.IO.BinaryReader R = new System.IO.BinaryReader( S ) )
                            for ( int coeffIndex=0; coeffIndex < ORDERS*ORDERS; coeffIndex++ )
                                coeffs[coeffIndex].Set( R.ReadSingle(), R.ReadSingle(), R.ReadSingle() );

                    // Write into a raw byte[]
                    byte[]	rawContent = new byte[400 * 4 * 4];
                    using ( System.IO.MemoryStream	MS = new System.IO.MemoryStream( rawContent ) )
                        using ( System.IO.BinaryWriter W = new System.IO.BinaryWriter( MS ) ) {
                            for ( int coeffIndex=0; coeffIndex < ORDERS*ORDERS; coeffIndex++ ) {
                                W.Write( coeffs[coeffIndex].x );
                                W.Write( coeffs[coeffIndex].y );
                                W.Write( coeffs[coeffIndex].z );
                                W.Write( 0.0f );
                            }
                        }
             					m_CB_Coeffs = new RawConstantBuffer( m_device, 1, rawContent.Length );
                    m_CB_Coeffs.UpdateData( rawContent );
                }

//.........这里部分代码省略.........
开发者ID:Patapom,项目名称:GodComplex,代码行数:101,代码来源:Form1.cs


注:本文中的Device.Init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。