Example #1
0
        void Run(TextureLevel target, string action)
        {
            frameBuffer.Colors[0].Attach(target);
            mainProgramAction.Subroutine = mainProgramAction.Compatible[action];

            Device.FrameBuffer = frameBuffer;
            mainProgram.Draw(Primitive.Quads, 4);
            Device.FrameBuffer = null;
        }
Example #2
0
        /// <summary>Save the texture to the file.</summary>
        /// <param name="texture"></param>
        /// <param name="writer"></param>
        public void Save(Texture texture, BinaryWriter writer)
        {
            Texture2D texture2d = texture as Texture2D;
            Vector3i  dimensions;
            int       pitchOrLinearSize;
            Flags     flags = RequiredFlags | Flags.MipMapCount;
            int       mipMapCount;

            dimensions = new Vector3i(texture2d.Dimensions, 1);
            for (mipMapCount = 0; texture2d.Levels[mipMapCount].Dimensions.Sum != 0; mipMapCount++)
            {
                ;
            }

            if (texture.Format.IsCompressed)
            {
                pitchOrLinearSize = texture.Format.AlignedByteSize(dimensions);
                flags            |= Flags.LinearSize;
            }
            else
            {
                pitchOrLinearSize = texture.Format.AlignedBytePitch(dimensions.X);
                flags            |= Flags.Pitch;
            }

            for (int index = 0; index < Magic.Length; index++)
            {
                writer.Write((byte)Magic[index]);
            }
            writer.Write(HeaderSize);
            writer.Write((int)flags);
            writer.Write(dimensions.X);
            writer.Write(dimensions.Y);
            writer.Write(pitchOrLinearSize);
            writer.Write(dimensions.Z);
            writer.Write(mipMapCount);
            for (int i = 0; i < 11; i++)
            {
                writer.Write(0);                 // Reserved
            }
            var pixelFormat = new PixelFormat(texture.Format);

            pixelFormat.Write(writer);

            writer.Write((int)(Caps.Texture));
            writer.Write((int)(Caps2.None));
            writer.Write(0);             // DDSCaps3, reserved
            writer.Write(0);             // DDSCaps4, reserved
            writer.Write(0);             // Reserved

            byte[] data = new byte[texture.Format.AlignedByteSize(dimensions)];
            for (int level = 0; level < mipMapCount; level++)
            {
                TextureLevel textureLevel = texture2d.Surface.Levels[level];

                textureLevel.Read(data, 0, texture.Format);
                int size = texture.Format.AlignedByteSize(textureLevel.Dimensions);
                writer.Write(data, 0, size);
            }
#if false
            Texture2D texture = new Texture2D();                    //format, new Vector2i(width, height));
            for (int level = 0; level < mipMapCount; level++)
            {
                if (reader.Read(data, 0, linearSize) != linearSize)
                {
                    throw new InvalidDataException();
                }
                texture.Surface.Levels[level].DataCompressed(format, new Vector2i(width, height), data);

                width      = (width + 1) / 2;
                height     = (height + 1) / 2;
                linearSize = format.AlignedByteSize(width, height);
            }

            texture.Name = path;
            return(texture);
#endif
        }
 public void Clear(double value, TextureLevel target)
 {
     Clear(new Vector4d(value), target);
 }
        void Run(TextureLevel target, string action)
        {
            frameBuffer.Colors[0].Attach(target);
            mainProgramAction.Subroutine = mainProgramAction.Compatible[action];

            Device.FrameBuffer = frameBuffer;
            mainProgram.Draw(Primitive.Quads, 4);
            Device.FrameBuffer = null;
        }
 public void Clear(Vector4d value, TextureLevel target)
 {
     mainProgram.Uniforms["ClearValue"].Set((Vector4f)value);
     Run(target, "Clear");
 }
Example #6
0
 public void Clear(Vector4d value, TextureLevel target)
 {
     mainProgram.Uniforms["ClearValue"].Set((Vector4f)value);
     Run(target, "Clear");
 }
Example #7
0
 public void Clear(double value, TextureLevel target)
 {
     Clear(new Vector4d(value), target);
 }