public Texture2DGL3x(Texture2DDescription description, TextureTarget textureTarget) { if (description.Width <= 0) { throw new ArgumentOutOfRangeException("description.Width", "description.Width must be greater than zero."); } if (description.Height <= 0) { throw new ArgumentOutOfRangeException("description.Height", "description.Height must be greater than zero."); } if (description.GenerateMipmaps) { if (textureTarget == TextureTarget.TextureRectangle) { throw new ArgumentException("description.GenerateMipmaps cannot be true for texture rectangles.", "description"); } if (!TextureUtility.IsPowerOfTwo(Convert.ToUInt32(description.Width))) { throw new ArgumentException("When description.GenerateMipmaps is true, the width must be a power of two.", "description"); } if (!TextureUtility.IsPowerOfTwo(Convert.ToUInt32(description.Height))) { throw new ArgumentException("When description.GenerateMipmaps is true, the height must be a power of two.", "description"); } } _name = new TextureNameGL3x(); _target = textureTarget; _description = description; _lastTextureUnit = OpenTKTextureUnit.Texture0 + (Device.NumberOfTextureUnits - 1); // // TexImage2D is just used to allocate the texture so a PBO can't be bound. // WritePixelBufferGL3x.UnBind(); BindToLastTextureUnit(); GL.TexImage2D(_target, 0, TypeConverterGL3x.To(description.TextureFormat), description.Width, description.Height, 0, TypeConverterGL3x.TextureToPixelFormat(description.TextureFormat), TypeConverterGL3x.TextureToPixelType(description.TextureFormat), new IntPtr()); // // Default sampler, compatiable when attaching a non-mimapped // texture to a frame buffer object. // ApplySampler(Device.TextureSamplers.LinearClamp); GC.AddMemoryPressure(description.ApproximateSizeInBytes); }