public static Texture WrapTexture(object texture, IntPtr nativePointer,
                                          int width, int height, int numLevels)
        {
            IntPtr texturePtr = Noesis_WrapTexture_(nativePointer, width, height, numLevels);

            Noesis.Texture tex = new Noesis.Texture(texturePtr, true);
            tex.SetPrivateData(texture != null ? new ManagedTexture {
                Texture = texture
            } : null);
            return(tex);
        }
Esempio n. 2
0
        private static Texture WrapTexture(object texture, IntPtr nativePointer,
                                           int width, int height, int numLevels)
        {
            IntPtr texturePtr = Noesis_WrapTexture(nativePointer, width, height, numLevels);

            Noesis.Texture tex = new Noesis.Texture(texturePtr, true);

            // A texture with the same pointer could be enqueued for release, just remove it
            // now to avoid an exception when adding the new texture to the dictionary
            if (Textures.ContainsKey(texturePtr.ToInt64()))
            {
                Noesis_RemoveEnqueuedTexture(texturePtr);
                Textures.Remove(texturePtr.ToInt64());
            }

            Textures.Add(texturePtr.ToInt64(), texture);

            return(tex);
        }
        public static Texture CreateNoesisTexture(Texture2D texture)
        {
            if (texture == null)
            {
                return(null);
            }

            if (texture.IsDisposed)
            {
                throw new Exception("Cannot wrap the disposed texture: " + texture);
            }

            var nativeTexture = (SharpDX.Direct3D11.Texture2D)TextureFieldInfo.Value.GetValue(texture);

            return(Texture.WrapD3D11Texture(
                       texture,
                       nativeTexture.NativePointer,
                       texture.Width,
                       texture.Height,
                       texture.LevelCount,
                       //FIXME format: GetTextureFormat(texture),
                       isInverted: false));
        }