CreateTexture2D() public method

Creates a 2D texture from the image
public CreateTexture2D ( RendererManaged _Device ) : RendererManaged.Texture2D
_Device RendererManaged
return RendererManaged.Texture2D
Esempio n. 1
0
//		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);
        }
Esempio n. 2
0
        //        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 );
        }