private ShaderResourceView GenerateTexture(IContext context, int sliceCount) { Texture1D provinceTexture = new Texture1D(context.DirectX.Device, new Texture1DDescription { Width = sliceCount, Format = Format.R32G32B32A32_Float, BindFlags = BindFlags.ShaderResource, ArraySize = 1, MipLevels = 1 }); int rowPitch = 16 * sliceCount; var byteArray = new byte[rowPitch]; for (int i = 0; i < sliceCount; i++) { CustomColor color = ColorInSlice(i); Array.Copy(BitConverter.GetBytes(color.Red), 0, byteArray, i * 16, 4); Array.Copy(BitConverter.GetBytes(color.Green), 0, byteArray, i * 16 + 4, 4); Array.Copy(BitConverter.GetBytes(color.Blue), 0, byteArray, i * 16 + 8, 4); Array.Copy(BitConverter.GetBytes(1.0f), 0, byteArray, i * 16 + 12, 4); } DataStream dataStream = new DataStream(rowPitch, true, true); dataStream.Write(byteArray, 0, rowPitch); DataBox data = new DataBox(dataStream.DataPointer, rowPitch, rowPitch); context.DirectX.DeviceContext.UpdateSubresource(data, provinceTexture); return(new ShaderResourceView(context.DirectX.Device, provinceTexture)); }
public static ShaderResourceView CreateRandomTexture1DSRV(Device device) { var randomValues = new List <Vector4>(); for (int i = 0; i < 1024; i++) { randomValues.Add(new Vector4(MathF.Rand(-1.0f, 1.0f), MathF.Rand(-1.0f, 1.0f), MathF.Rand(-1.0f, 1.0f), MathF.Rand(-1.0f, 1.0f))); } var texDesc = new Texture1DDescription() { ArraySize = 1, BindFlags = BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.None, Format = Format.R32G32B32A32_Float, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, Usage = ResourceUsage.Immutable, Width = 1024 }; var randTex = new Texture1D(device, texDesc, new DataStream(randomValues.ToArray(), false, false)); var viewDesc = new ShaderResourceViewDescription() { Format = texDesc.Format, Dimension = ShaderResourceViewDimension.Texture1D, MipLevels = texDesc.MipLevels, MostDetailedMip = 0 }; var randTexSRV = new ShaderResourceView(device, randTex, viewDesc); ReleaseCom(ref randTex); return(randTexSRV); }
internal DataBox MapSubresource(Texture1D resource, int mipSlice, int arraySlice, MapMode mode, MapFlags flags, out DataStream stream) { return(m_deviceContext.MapSubresource(resource, mipSlice, arraySlice, mode, flags, out stream)); CheckErrors(); }
private void InitializeFromImpl(DataBox[] dataBoxes = null) { if (ParentTexture != null) { NativeDeviceChild = ParentTexture.NativeDeviceChild; } if (NativeDeviceChild == null) { switch (Dimension) { case TextureDimension.Texture1D: NativeDeviceChild = new Texture1D(GraphicsDevice.NativeDevice, ConvertToNativeDescription1D(), ConvertDataBoxes(dataBoxes)); break; case TextureDimension.Texture2D: case TextureDimension.TextureCube: NativeDeviceChild = new Texture2D(GraphicsDevice.NativeDevice, ConvertToNativeDescription2D(), ConvertDataBoxes(dataBoxes)); break; case TextureDimension.Texture3D: NativeDeviceChild = new Texture3D(GraphicsDevice.NativeDevice, ConvertToNativeDescription3D(), ConvertDataBoxes(dataBoxes)); break; } GraphicsDevice.RegisterTextureMemoryUsage(SizeInBytes); } NativeShaderResourceView = GetShaderResourceView(ViewType, ArraySlice, MipLevel); NativeUnorderedAccessView = GetUnorderedAccessView(ViewType, ArraySlice, MipLevel); NativeRenderTargetView = GetRenderTargetView(ViewType, ArraySlice, MipLevel); NativeDepthStencilView = GetDepthStencilView(out HasStencil); }
public void Resize( int length ) { if( Length == length || length == 0 ) { return; } Length = length; if( Texture != null ) { View.Dispose(); Texture.Dispose(); } var desc = new Texture1DDescription { Width = length, MipLevels = 1, ArraySize = 1, Format = Format.R32G32B32A32_Float, Usage = ResourceUsage.Dynamic, BindFlags = BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.Write, OptionFlags = ResourceOptionFlags.None }; Texture = new Texture1D( D3D10Wrapper.Instance.Device, desc ); View = new ShaderResourceView( D3D10Wrapper.Instance.Device, Texture ); }
/// <summary> /// Gets the data of the entire <see cref="Texture1D"/>. /// </summary> /// <param name="texture">The <see cref="Texture1D"/> to get the image from.</param> /// <param name="image">The image in which to write the pixel data.</param> public static void GetData(this Texture1D texture, Image <Rgba32> image) { if (texture == null) { throw new ArgumentNullException(nameof(texture)); } if (texture.ImageFormat != TextureImageFormat.Color4b) { throw new ArgumentException(nameof(texture), ImageUtils.TextureFormatMustBeColor4bError); } if (image == null) { throw new ArgumentNullException(nameof(image)); } if (image.Width * image.Height != texture.Width) { throw new ArgumentException(nameof(image), ImageUtils.ImageSizeMustMatchTextureSizeError); } if (!image.TryGetSinglePixelSpan(out Span <Rgba32> pixels)) { throw new InvalidDataException(ImageUtils.ImageNotContiguousError); } texture.GetData(pixels, PixelFormat.Rgba); }
public void SaveTXT( string filename ) { var device = D3D10Wrapper.Instance.Device; // copy to CPU var ctd = Texture.Description; ctd.Usage = ResourceUsage.Staging; ctd.BindFlags = BindFlags.None; ctd.CpuAccessFlags = CpuAccessFlags.Read | CpuAccessFlags.Write; using( var cpuTexture = new Texture1D( device, ctd ) ) { device.CopyResource( Texture, cpuTexture ); var stream = cpuTexture.Map( 0, MapMode.Read, MapFlags.None ); using( var sw = new StreamWriter( filename ) ) for( int i = 0; i < Length; ++i ) { var x = stream.Read< float >(); var y = stream.Read< float >(); var z = stream.Read< float >(); var w = stream.Read< float >(); sw.WriteLine( "{0}: {1}, {2}, {3}, {4}", i, x, y, z, w ); } stream.Close(); cpuTexture.Unmap( 0 ); } }
private ShaderResourceView GenerateProvinceTexture(IContext context, IList <LandProvince> provinces, Func <LandProvince, CustomColor> colorGenerator) { int maxId = provinces.Max(p => p.NumericId); Texture1D provinceTexture = new Texture1D(context.DirectX.Device, new Texture1DDescription { Width = maxId + 1, Format = Format.R32G32B32A32_Float, BindFlags = BindFlags.ShaderResource, ArraySize = 1, MipLevels = 1 }); int rowPitch = 16 * provinceTexture.Description.Width; var byteArray = new byte[rowPitch]; foreach (LandProvince province in provinces) { CustomColor color = colorGenerator(province); Array.Copy(BitConverter.GetBytes(color.Red), 0, byteArray, province.NumericId * 16, 4); Array.Copy(BitConverter.GetBytes(color.Green), 0, byteArray, province.NumericId * 16 + 4, 4); Array.Copy(BitConverter.GetBytes(color.Blue), 0, byteArray, province.NumericId * 16 + 8, 4); Array.Copy(BitConverter.GetBytes(1.0f), 0, byteArray, province.NumericId * 16 + 12, 4); } DataStream dataStream = new DataStream(rowPitch, true, true); dataStream.Write(byteArray, 0, rowPitch); DataBox data = new DataBox(dataStream.DataPointer, rowPitch, rowPitch); //ResourceRegion region = new ResourceRegion(); context.DirectX.DeviceContext.UpdateSubresource(data, provinceTexture); return(new ShaderResourceView(context.DirectX.Device, provinceTexture)); }
private void InitializeFromImpl(DataBox[] dataBoxes = null) { if (ParentTexture != null) { NativeDeviceChild = ParentTexture.NativeDeviceChild; } if (NativeDeviceChild == null) { switch (Dimension) { case TextureDimension.Texture1D: NativeDeviceChild = new Texture1D(GraphicsDevice.NativeDevice, ConvertToNativeDescription1D(), ConvertDataBoxes(dataBoxes)); break; case TextureDimension.Texture2D: case TextureDimension.TextureCube: NativeDeviceChild = new Texture2D(GraphicsDevice.NativeDevice, ConvertToNativeDescription2D(), ConvertDataBoxes(dataBoxes)); break; case TextureDimension.Texture3D: NativeDeviceChild = new Texture3D(GraphicsDevice.NativeDevice, ConvertToNativeDescription3D(), ConvertDataBoxes(dataBoxes)); break; } GraphicsDevice.RegisterTextureMemoryUsage(SizeInBytes); } if (NativeShaderResourceView == null) { NativeShaderResourceView = GetShaderResourceView(ViewType, ArraySlice, MipLevel); } NativeUnorderedAccessView = GetUnorderedAccessView(ViewType, ArraySlice, MipLevel); NativeRenderTargetView = GetRenderTargetView(ViewType, ArraySlice, MipLevel); NativeDepthStencilView = GetDepthStencilView(out HasStencil); switch (textureDescription.Options) { case TextureOptions.None: SharedHandle = IntPtr.Zero; break; case TextureOptions.Shared: var sharedResource = NativeDeviceChild.QueryInterface <SharpDX.DXGI.Resource>(); SharedHandle = sharedResource.SharedHandle; break; #if STRIDE_GRAPHICS_API_DIRECT3D11 case TextureOptions.SharedNthandle | TextureOptions.SharedKeyedmutex: var sharedResource1 = NativeDeviceChild.QueryInterface <SharpDX.DXGI.Resource1>(); var uniqueName = "Stride:" + Guid.NewGuid().ToString(); SharedHandle = sharedResource1.CreateSharedHandle(uniqueName, SharpDX.DXGI.SharedResourceFlags.Write); SharedNtHandleName = uniqueName; break; #endif default: throw new ArgumentOutOfRangeException("textureDescription.Options"); } }
public Texture1DArrayView(Texture1D resource, RenderTargetViewDescription.Texture1DArrayResource description) { _subresources = new Texture1D.Texture1DSubresource[description.ArraySize]; for (int i = description.FirstArraySlice; i < description.FirstArraySlice + description.ArraySize; i++) { _subresources[i] = resource.GetSubresource(i, description.MipSlice); } }
public void Evaluate(int SpreadMax) { this.FOutValid.SliceCount = 1; if (this.FTextureIn.PluginIO.IsConnected) { if (this.RenderRequest != null) { this.RenderRequest(this, this.FHost); } if (this.AssignedContext == null) { this.FOutValid.SliceCount = 0; return; } //Do NOT cache this, assignment done by the host DX11RenderContext context = this.AssignedContext; for (int i = 0; i < SpreadMax; i++) { if (this.FTextureIn[i].Contains(context) && this.FInSave[i]) { if (this.FCreateFolder[0]) { string path = Path.GetDirectoryName(this.FInPath[i]); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } } try { string path = this.FInPath[i]; if (!path.EndsWith(".dds", StringComparison.InvariantCultureIgnoreCase)) { path += ".dds"; } Texture1D.SaveTextureToFile(this.AssignedContext.CurrentDeviceContext, this.FTextureIn[i][context].Resource, ImageFileFormat.Dds, path); this.FOutValid[0] = true; } catch (Exception ex) { FLogger.Log(ex); this.FOutValid[0] = false; } } else { this.FOutValid[0] = false; } } } else { this.FOutValid.SliceCount = 0; } }
public static DX11Texture1D FromReference(DxDevice device, Texture1D texture, ShaderResourceView view) { DX11Texture1D result = new DX11Texture1D(device); result.description = texture.Description; result.ShaderView = view; result.Texture = texture; return(result); }
public void GetPixel_DoesClamp() { int width = 2; int bitDepth = 32; Texture1D tex = CreateXFilledTexture(width, bitDepth, TEXTURE_WRAP.CLAMP); Assert.AreEqual(0, tex.GetPixel(-1, 0).r); Assert.AreEqual(1, tex.GetPixel(2, 0).r); }
/// <summary> /// Sets the value. /// </summary> /// <param name="value">The texture.</param> public void SetValue(Texture value) { if (_paramClass != EffectParameterClass.Object) { throw new InvalidCastException("Parameter is not a texture."); } if (value == null) { throw new ArgumentNullException("Texture cannot be null"); } switch (_paramType) { case EffectParameterType.Texture1D: Texture1D tex1D = value as Texture1D; if (tex1D == null) { throw new InvalidCastException("Expecting Texture1D"); } _param.SetValue(((XNATexture1DImplementation)tex1D.Implementation).XNATexture1D); _cachedTexture = value; break; case EffectParameterType.Texture2D: Texture2D tex2D = value as Texture2D; if (tex2D == null) { throw new InvalidCastException("Expecting Texture2D"); } _param.SetValue(((XNATexture2DImplementation)tex2D.Implementation).XNATexture2D); _cachedTexture = value; break; case EffectParameterType.Texture3D: Texture3D tex3D = value as Texture3D; if (tex3D == null) { throw new InvalidCastException("Expecting Texture3D"); } _param.SetValue(((XNATexture3DImplementation)tex3D.Implementation).XNATexture3D); _cachedTexture = value; break; case EffectParameterType.TextureCube: TextureCube texCube = value as TextureCube; if (texCube == null) { throw new InvalidCastException("Expecting Texture3D"); } _param.SetValue(((XNATextureCubeImplementation)texCube.Implementation).XNATextureCube); _cachedTexture = value; break; } }
public void SetPixel() { Texture1D tex = new Texture1D(2, 4, 32); tex.SetPixel(0, new ColorRGBA(1, 2, 3, 4)); Assert.AreEqual(1, tex.GetChannel(0, 0)); Assert.AreEqual(2, tex.GetChannel(0, 1)); Assert.AreEqual(3, tex.GetChannel(0, 2)); Assert.AreEqual(4, tex.GetChannel(0, 3)); }
public void DimensionsCorrect() { int width = 512; int channels = 3; int bitDepth = 8; Texture1D tex = new Texture1D(width, channels, bitDepth); Assert.AreEqual(width, tex.GetWidth()); Assert.AreEqual(channels, tex.Channels); Assert.AreEqual(bitDepth, tex.BitDepth); }
Texture1D CreateXFilledTexture(int width, int bitDepth, TEXTURE_WRAP wrap) { Texture1D tex = new Texture1D(width, 2, bitDepth); tex.Wrap = wrap; for (int x = 0; x < width; x++) { tex.SetChannel(x, 0, x); } return(tex); }
public void ResizeBitDepth_DoesResize() { int width = 2; int channels = 3; int bitDepth = 32; Texture1D tex = new Texture1D(width, channels, bitDepth); bitDepth = 8; tex.Resize(width, channels, bitDepth); Assert.AreEqual(bitDepth, tex.BitDepth); }
public void ResizeChannels_DoesResize() { int width = 2; int channels = 3; int bitDepth = 32; Texture1D tex = new Texture1D(width, channels, bitDepth); channels = 4; tex.Resize(width, channels, bitDepth); Assert.AreEqual(channels, tex.Channels); }
private Texture1D CreateTexture1D(MipMapChain mipMapChain) { ImageData mip0 = mipMapChain[0]; Texture1D tex = new Texture1D(mip0.Width, (mipMapChain.Count > 1), GetSurfaceFormat(mip0)); for (int i = 0; i < mipMapChain.Count; i++) { ImageData mip = mipMapChain[i]; byte[] data = (mip.HasCompressedData) ? mip.CompressedData : mip.Data; tex.SetData <byte>(data, i, 0, mip.Width, 0, data.Length); } return(tex); }
private void BuildRandomTexture() { // // Create the random data. // var rand = new Random(); var randomValues = new Vector4[1024]; for (int i = 0; i < 1024; ++i) { randomValues[i] = new Vector4(rand.RandF(-1.0f, 1.0f), rand.RandF(-1.0f, 1.0f), rand.RandF(-1.0f, 1.0f), rand.RandF(-1.0f, 1.0f)); } // // Create the texture. // var texDesc = new Texture1DDescription { Width = 1024, MipLevels = 1, Format = Format.R32G32B32A32_Float, Usage = ResourceUsage.Immutable, BindFlags = BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None, ArraySize = 1 }; var ds = new DataStream(randomValues, true, false); var randomTex = new Texture1D(_dxDevice, texDesc, ds); ds.Close(); // // Create the resource view. // var viewDesc = new ShaderResourceViewDescription { Format = texDesc.Format, Dimension = ShaderResourceViewDimension.Texture1D, MipLevels = texDesc.MipLevels, MostDetailedMip = 0 }; _randomTexRV = new ShaderResourceView(_dxDevice, randomTex, viewDesc); randomTex.Dispose(); }
public void TestTexture1DMipMap() { var device = GraphicsDevice.New(); // Check texture creation with an array of data, with usage default to later allow SetData var data = new byte[256]; data[0] = 255; data[31] = 1; var texture = Texture1D.New(device, 256, true, PixelFormat.R8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget); // Verify the number of mipmap levels Assert.That(texture.Description.MipLevels, Is.EqualTo(Math.Log(data.Length, 2) + 1)); // Get a render target on the mipmap 1 (128) with value 1 and get back the data var renderTarget1 = texture.ToRenderTarget(ViewType.Single, 0, 1); device.Clear(renderTarget1, new Color4(0xFF000001)); var data1 = texture.GetData <byte>(0, 1); Assert.That(data1.Length, Is.EqualTo(128)); Assert.That(data1[0], Is.EqualTo(1)); renderTarget1.Dispose(); // Get a render target on the mipmap 2 (128) with value 2 and get back the data var renderTarget2 = texture.ToRenderTarget(ViewType.Single, 0, 2); device.Clear(renderTarget2, new Color4(0xFF000002)); var data2 = texture.GetData <byte>(0, 2); Assert.That(data2.Length, Is.EqualTo(64)); Assert.That(data2[0], Is.EqualTo(2)); renderTarget2.Dispose(); // Get a render target on the mipmap 3 (128) with value 3 and get back the data var renderTarget3 = texture.ToRenderTarget(ViewType.Single, 0, 3); device.Clear(renderTarget3, new Color4(0xFF000003)); var data3 = texture.GetData <byte>(0, 3); Assert.That(data3.Length, Is.EqualTo(32)); Assert.That(data3[0], Is.EqualTo(3)); renderTarget3.Dispose(); // Release the texture texture.Dispose(); device.Dispose(); }
Texture1D CreateIndexFilledTexture(int width, int channels, int bitDepth) { Texture1D tex = new Texture1D(width, channels, bitDepth); for (int x = 0; x < width; x++) { for (int c = 0; c < channels; c++) { int idx = (x * channels) + c; tex.SetChannel(x, c, idx); } } return(tex); }
public void MipMapsHaveCorrectDimensions(int mipLevel, int expectedWidth) { // Arrange. var texture = new Texture1D(new Device(), new Texture1DDescription { Width = 64, ArraySize = 1 }); // Act / Assert. int actualWidth; texture.GetDimensions(mipLevel, out actualWidth); Assert.That(actualWidth, Is.EqualTo(expectedWidth)); }
public void GetChannels_DoesClamp() { int width = 2; int bitDepth = 32; Texture1D tex = CreateXFilledTexture(width, bitDepth, TEXTURE_WRAP.CLAMP); float[] tmp = new float[2]; tex.GetChannels(-1, tmp); Assert.AreEqual(0, tmp[0]); tex.GetChannels(2, tmp); Assert.AreEqual(1, tmp[0]); }
public void GetChannel_DoesClamp() { int width = 4; int bitDepth = 32; Texture1D tex = CreateXFilledTexture(width, bitDepth, TEXTURE_WRAP.CLAMP); Assert.AreEqual(0, tex.GetChannel(-2, 0)); Assert.AreEqual(0, tex.GetChannel(-1, 0)); Assert.AreEqual(0, tex.GetChannel(0, 0)); Assert.AreEqual(1, tex.GetChannel(1, 0)); Assert.AreEqual(2, tex.GetChannel(2, 0)); Assert.AreEqual(3, tex.GetChannel(3, 0)); Assert.AreEqual(3, tex.GetChannel(4, 0)); Assert.AreEqual(3, tex.GetChannel(5, 0)); }
public void TextureHasCorrectNumberOfMipMapLevels() { // Arrange. var texture = new Texture1D(new Device(), new Texture1DDescription { Width = 32, ArraySize = 1 }); int width, numberOfLevels; // Act. texture.GetDimensions(0, out width, out numberOfLevels); // Assert. Assert.That(width, Is.EqualTo(32)); Assert.That(numberOfLevels, Is.EqualTo(6)); }
public void GetChannel() { int width = 65; int channels = 3; int bitDepth = 32; Texture1D tex = CreateIndexFilledTexture(width, channels, bitDepth); for (int x = 0; x < width; x++) { for (int c = 0; c < channels; c++) { int idx = (x * channels) + c; Assert.AreEqual(idx, tex.GetChannel(x, c)); } } }
public void BilinearFilter_DoesMirror() { int width = 2; int bitDepth = 32; Texture1D tex = CreateXFilledTexture(width, bitDepth, TEXTURE_WRAP.MIRROR); Assert.AreEqual(0.5f, tex.GetChannel(-0.5f, 0)); Assert.AreEqual(0.25f, tex.GetChannel(-0.25f, 0)); Assert.AreEqual(0.0f, tex.GetChannel(0.0f, 0)); Assert.AreEqual(0.25f, tex.GetChannel(0.25f, 0)); Assert.AreEqual(0.5f, tex.GetChannel(0.5f, 0)); Assert.AreEqual(0.75f, tex.GetChannel(0.75f, 0)); Assert.AreEqual(1.0f, tex.GetChannel(1.0f, 0)); Assert.AreEqual(0.75f, tex.GetChannel(1.25f, 0)); Assert.AreEqual(0.5f, tex.GetChannel(1.5f, 0)); }
public void GetPixel() { int width = 65; int channels = 4; int bitDepth = 32; Texture1D tex = CreateIndexFilledTexture(width, channels, bitDepth); for (int x = 0; x < width; x++) { ColorRGBA col = tex.GetPixel(x); Assert.AreEqual((x * channels) + 0, col.r); Assert.AreEqual((x * channels) + 1, col.g); Assert.AreEqual((x * channels) + 2, col.b); Assert.AreEqual((x * channels) + 3, col.a); } }
public void DataTypeCorrect() { int width = 512; int channels = 3; Texture1D tex = null; tex = new Texture1D(width, channels, 8); Assert.IsInstanceOfType(tex.Data, typeof(TextureData1D8)); Assert.AreEqual(8, tex.BitDepth); tex = new Texture1D(width, channels, 16); Assert.IsInstanceOfType(tex.Data, typeof(TextureData1D16)); Assert.AreEqual(16, tex.BitDepth); tex = new Texture1D(width, channels, 32); Assert.IsInstanceOfType(tex.Data, typeof(TextureData1D32)); Assert.AreEqual(32, tex.BitDepth); }
public void GetChannel_DoesMirror() { int width = 4; int bitDepth = 32; Texture1D tex = CreateXFilledTexture(width, bitDepth, TEXTURE_WRAP.MIRROR); tex.Wrap = TEXTURE_WRAP.MIRROR; Assert.AreEqual(2, tex.GetChannel(-2, 0)); Assert.AreEqual(1, tex.GetChannel(-1, 0)); Assert.AreEqual(0, tex.GetChannel(0, 0)); Assert.AreEqual(1, tex.GetChannel(1, 0)); Assert.AreEqual(2, tex.GetChannel(2, 0)); Assert.AreEqual(3, tex.GetChannel(3, 0)); Assert.AreEqual(2, tex.GetChannel(4, 0)); Assert.AreEqual(1, tex.GetChannel(5, 0)); }
public void Set(Texture1D texture) { if (location != -1) { Debug.Assert(type == UniformType.Sampler1D); GL.ActiveTexture(unit); GL.BindTexture(TextureTarget.Texture1D, texture.Handle); GL.Uniform(location, unit - TextureUnit.Texture0); } }
private void InitializeFromImpl(DataBox[] dataBoxes = null) { if (ParentTexture != null) { NativeDeviceChild = ParentTexture.NativeDeviceChild; } if (NativeDeviceChild == null) { switch (Dimension) { case TextureDimension.Texture1D: NativeDeviceChild = new Texture1D(GraphicsDevice.NativeDevice, ConvertToNativeDescription1D(), ConvertDataBoxes(dataBoxes)); break; case TextureDimension.Texture2D: case TextureDimension.TextureCube: NativeDeviceChild = new Texture2D(GraphicsDevice.NativeDevice, ConvertToNativeDescription2D(), ConvertDataBoxes(dataBoxes)); break; case TextureDimension.Texture3D: NativeDeviceChild = new Texture3D(GraphicsDevice.NativeDevice, ConvertToNativeDescription3D(), ConvertDataBoxes(dataBoxes)); break; } } NativeShaderResourceView = GetShaderResourceView(ViewType, ArraySlice, MipLevel); NativeUnorderedAccessView = GetUnorderedAccessView(ViewType, ArraySlice, MipLevel); NativeRenderTargetView = GetRenderTargetView(ViewType, ArraySlice, MipLevel); NativeDepthStencilView = GetDepthStencilView(out HasStencil); }
public void AttachTexture(Texture1D tex) { MakeCurrent(); OpenGL.glFramebufferTexture1D(OpenGL.Const.GL_FRAMEBUFFER, OpenGL.Const.GL_COLOR_ATTACHMENT0, OpenGL.Const.GL_TEXTURE_1D, tex.Handle, 0); }
public void SetTexture1D(FramebufferAttachment attachment, int miplevel, Texture1D texture) { GL.BindFramebuffer(FramebufferType.Framebuffer, framebuffer); GL.FramebufferTexture1D(FramebufferType.Framebuffer, attachment, TextureTarget.Texture1D, texture == null ? 0 : texture.Handle, miplevel); SetTextureAttachment(attachment, texture); }
protected internal Texture1D(GraphicsDevice device, Texture1D texture) : base(device, texture.Description) { }