Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UserInterfaceRenderer10"/> class.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="width">The width of the renderable area.</param>
        /// <param name="height">The height of the renderable area.</param>
        public UserInterfaceRenderer10(D3D.Device device, int width, int height)
        {
            if (device == null)
                throw new ArgumentNullException("device");
            if (width < 0)
                throw new ArgumentException("Value must be positive.", "width");
            if (height < 0)
                throw new ArgumentException("Value must be positive.", "height");

            this.device = device;
            halfWidth = width / 2;
            halfHeight = height / 2;

            font = new D3D.Font(device, 18, 0, D3D.FontWeight.Bold, 0, false, D3D.FontCharacterSet.Default, D3D.FontPrecision.Default, D3D.FontQuality.Antialiased, D3D.FontPitchAndFamily.Default, "Arial");
            sprite = new SlimDX.Direct3D10.Sprite(device, 0);
            lineBuffer = new DynamicPrimitiveBuffer10<ColoredVertex>(device);

            Assembly assembly = Assembly.GetExecutingAssembly();
            using (Stream stream = assembly.GetManifestResourceStream("SampleFramework.Resources.UserInterface10.fx"))
            using (StreamReader reader = new StreamReader(stream))
            {
                effect = D3D.Effect.FromString(device, reader.ReadToEnd(), "fx_4_0");
            }

            technique = effect.GetTechniqueByIndex(0);
            pass = technique.GetPassByIndex(0);

            ShaderSignature signature = pass.Description.Signature;
            inputLayout = new D3D.InputLayout(device, signature, new[] {
				new D3D.InputElement("POSITION", 0, SlimDX.DXGI.Format.R32G32B32_Float, 0, 0),
				new D3D.InputElement("COLOR", 0, SlimDX.DXGI.Format.R8G8B8A8_UNorm, D3D.InputElement.AppendAligned, 0 )
			});
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UserInterfaceRenderer10"/> class.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="width">The width of the renderable area.</param>
        /// <param name="height">The height of the renderable area.</param>
        public UserInterfaceRenderer10(D3D.Device device, int width, int height)
        {
            if (device == null)
            {
                throw new ArgumentNullException("device");
            }
            if (width < 0)
            {
                throw new ArgumentException("Value must be positive.", "width");
            }
            if (height < 0)
            {
                throw new ArgumentException("Value must be positive.", "height");
            }

            this.device = device;
            halfWidth   = width / 2;
            halfHeight  = height / 2;

            font       = new D3D.Font(device, 18, 0, D3D.FontWeight.Bold, 0, false, D3D.FontCharacterSet.Default, D3D.FontPrecision.Default, D3D.FontQuality.Antialiased, D3D.FontPitchAndFamily.Default, "Arial");
            sprite     = new SlimDX.Direct3D10.Sprite(device, 0);
            lineBuffer = new DynamicPrimitiveBuffer10 <ColoredVertex>(device);

            Assembly assembly = Assembly.GetExecutingAssembly();

            using (Stream stream = assembly.GetManifestResourceStream("SampleFramework.Resources.UserInterface10.fx"))
                using (StreamReader reader = new StreamReader(stream))
                {
                    effect = D3D.Effect.FromString(device, reader.ReadToEnd(), "fx_4_0");
                }

            technique = effect.GetTechniqueByIndex(0);
            pass      = technique.GetPassByIndex(0);

            ShaderSignature signature = pass.Description.Signature;

            inputLayout = new D3D.InputLayout(device, signature, new[] {
                new D3D.InputElement("POSITION", 0, SlimDX.DXGI.Format.R32G32B32_Float, 0, 0),
                new D3D.InputElement("COLOR", 0, SlimDX.DXGI.Format.R8G8B8A8_UNorm, D3D.InputElement.AppendAligned, 0)
            });
        }
Ejemplo n.º 3
0
        private D3D10.Sprite sprite; //2D sprite which is used to draw interface modules (only to speed up the whole process)

        #endregion Fields

        #region Constructors

        //Interface creation classes
        /// <summary>
        /// Private constructor, 'cos it is a singleton. It makes basic preparations for drawing/using the user interface
        /// </summary>
        /// <param name="d">Instance of DX10 device</param>
        private Interface()
        {
            sprite = new SlimDX.Direct3D10.Sprite(Game.gameClass.GetDevice(), 100);
            modules = new StdVector<InterfaceModule>(10);
            modulesNames = new Dictionary<string, InterfaceModule>();
        }