Example #1
0
        /// <summary>
        ///     Constructor privado para poder hacer el singleton
        /// </summary>
        private TgcDrawText()
        {
            TextSprite = new Directx.Sprite(D3DDevice.Instance.Device);

            //Fuente default
            dxFont = new Directx.Font(D3DDevice.Instance.Device, VERDANA_10);
        }
Example #2
0
        /// <summary>
        /// Constructs the font object using the desired font family. If the desired family
        /// is not supported, the fallback family defined in the Settings file is used.
        /// </summary>
        public Font(Renderer renderer, string familyName, int height)
        {
            this.renderer = renderer;
            this.familyName = familyName;
            this.height = height + 5;

            // Attempt to create the Windows font object
            try
            {
                windowsFont = new System.Drawing.Font(familyName, this.height,
                    System.Drawing.FontStyle.Regular);
            }
            catch
            {
                // Attempt to create the font using the "fallback" font family
                // defined in the Settings file
                Log.Write("The desired font family was not available. Falling back on the default " +
                    "family defined in the Settings file.");
                windowsFont = new System.Drawing.Font(Dynamic2DLighting.Properties.Settings.Default.FallbackFontFamily,
                    this.height, System.Drawing.FontStyle.Regular);
            }

            d3dFont = new Direct3D.Font(renderer.Device, windowsFont);
            textSprite = new Direct3D.Sprite(renderer.Device);

            renderer.AddGraphicsObject(this);
        }
Example #3
0
        /// <summary>Initializes DirectX graphics</summary>
        /// <returns>true on success, false on failure</returns>
        private bool InitializeGraphics()
        {
            try
            {
                PresentParameters presentParams = new PresentParameters();
                presentParams.Windowed               = true;
                presentParams.SwapEffect             = SwapEffect.Discard;
                presentParams.BackBufferFormat       = Format.Unknown;
                presentParams.AutoDepthStencilFormat = DepthFormat.D16;
                presentParams.EnableAutoDepthStencil = true;

                int         adapterOrdinal = D3D.Manager.Adapters.Default.Adapter;
                CreateFlags flags          = CreateFlags.SoftwareVertexProcessing;
                D3D.Caps    caps           = D3D.Manager.GetDeviceCaps(adapterOrdinal, D3D.DeviceType.Hardware);
                if (caps.DeviceCaps.SupportsHardwareTransformAndLight)
                {
                    flags = CreateFlags.HardwareVertexProcessing;
                }

                device                 = new Device(0, DeviceType.Hardware, this, flags, presentParams);
                device.DeviceLost     += new EventHandler(this.InvalidateDeviceObjects);
                device.DeviceReset    += new EventHandler(this.RestoreDeviceObjects);
                device.Disposing      += new EventHandler(this.DeleteDeviceObjects);
                device.DeviceResizing += new CancelEventHandler(this.EnvironmentResizeing);

                d3dsprite = new Sprite(device);
                return(true);
            }
            catch (DirectXException)
            {
                return(false);
            }
        }
Example #4
0
        // --------------------------------------------------------------------
        // Tell a Direct3D.Sprite object how to render this sprite
        // --------------------------------------------------------------------
        public void Draw(Direct3D.Sprite renderer, Camera camera)
        {
            // calculate the actual width and height:
            float w = XScale * Width;
            float h = YScale * Height;

            // calculate the actual anchor point in sprite coordinates:
            DirectX.Vector2 scaledanchor = anchor;
            scaledanchor.X *= w;
            scaledanchor.Y *= h;

            DirectX.Vector2 newoffset = offset;
            newoffset.X -= scaledanchor.X;
            newoffset.Y -= scaledanchor.Y;


            renderer.Draw(
                texture,
                rect,
                scaling,
                scaledanchor,
                angle,
                newoffset - camera.Offset,
                color);
        }
Example #5
0
        public bool LoadImage(Device device, Bitmap bitmap, string typeName, int cols, int rows)
        {
            //return true;

            //_Texture = TextureLoader.FromFile(device, Application.StartupPath + @"\..\..\banana.bmp");

            //using (Bitmap bmp = new Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb))
            //{
            //    bitmapData = bmp.LockBits(bounds, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
            //    Marshal.Copy(screenData, 0, bitmapData.Scan0, screenData.Length);
            //    bmp.UnlockBits(bitmapData);

            //    texture = Texture.FromBitmap(d3dDevice, bmp, 0, Pool.SystemMemory);
            //}

            //texture = TextureLoader.FromStream(dev,
            //      Assembly.GetExecutingAssembly().GetManifestResourceStream(
            //      "Texture.Content.Banana.bmp"));

            //_Texture = Texture.FromBitmap(device, bitmap, 0, Pool.Managed);

            bool ret = _TextureDic.TryGetValue(bitmap, out _Texture);

            if (ret == false)
            {
                _Texture = CreateDirectXTexture(bitmap, device);
            }

            m_ImageSize.cx = bitmap.Width;
            m_ImageSize.cy = bitmap.Height;

            _Sprite = new Microsoft.DirectX.Direct3D.Sprite(device);

            return(true);
        }
Example #6
0
        public override void DrawText(Point dest_pt, string text)
        {
            if (mSprite == null)
            {
                mSprite = new Microsoft.DirectX.Direct3D.Sprite(mD3DFont.Device);
            }

            Point dest = Origin.Calc(DisplayAlignment, StringDisplaySize(text));


            dest_pt.X -= dest.X;
            dest_pt.Y -= dest.Y;

            double scalex, scaley;

            GetScale(out scalex, out scaley);

            mDisplay.D3D_Device.DrawBuffer.Flush();
            mDisplay.D3D_Device.SetFontRenderState();

            mSprite.Begin(SpriteFlags.AlphaBlend);
            mSprite.Transform = Matrix.Scaling((float)scalex, (float)scaley, 1.0f)
                                * Matrix.Translation(dest_pt.X, dest_pt.Y, 0);

            mD3DFont.DrawText(mSprite, text, new System.Drawing.Point(0, 0), Color.ToArgb());

            mSprite.End();
        }
        /// <summary>
        /// Initializes the Managed Texture Manager.
        /// </summary>
        /// <param name="device">Direct3D device.</param>
        /// <param name="sprite">Sprite device.</param>
        /// <returns>true if successful, false otherwise.</returns>
        public bool InitManagedTextureManager(Microsoft.DirectX.Direct3D.Device device, Microsoft.DirectX.Direct3D.Sprite sprite)
        {
            this.device   = device;
            this.sprite   = sprite;
            this.textures = new System.Collections.ArrayList();

            return(device != null && sprite != null);
        }
Example #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Pendulum"/> class.
 /// </summary>
 /// <param name="g">The graphic device to draw the pendulum to</param>
 /// <param name="gSize">Size of graphic display</param>
 /// <param name="texture">The texture to dispaly as the pendulum</param>
 /// <param name="sound">The sound to play as the pendulum swings</param>
 public Pendulum(Direct3D.Device g, Size gSize, Direct3D.Texture texture, SecondaryBuffer sound)
 {
     _sWidth   = gSize.Width;
     _graphics = g;
     _sprite   = new Direct3D.Sprite(_graphics);
     _texture  = texture;
     _sound    = sound;
 }
Example #9
0
        void init()
        {
            Microsoft.DirectX.Direct3D.PresentParameters pps = new Microsoft.DirectX.Direct3D.PresentParameters();
            pps.SwapEffect           = Microsoft.DirectX.Direct3D.SwapEffect.Discard;
            pps.Windowed             = true;
            pps.BackBufferCount      = 1;
            pps.PresentationInterval = PresentInterval.One;
            pps.BackBufferFormat     = Format.A8R8G8B8;

            if (GameWindow == null)
            {
                //pps.BackBufferWidth = GameControl.Width;
                //pps.BackBufferHeight = GameControl.Height;
                D3DDev = new Microsoft.DirectX.Direct3D.Device(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, GameControl, Microsoft.DirectX.Direct3D.CreateFlags.SoftwareVertexProcessing, pps);
            }
            else
            {
                //pps.BackBufferWidth = GameWindow.Width;
                //pps.BackBufferHeight = GameWindow.Height;
                D3DDev = new Microsoft.DirectX.Direct3D.Device(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, GameWindow, Microsoft.DirectX.Direct3D.CreateFlags.SoftwareVertexProcessing, pps);
            }
            D3DDev.VertexFormat = CustomVertex.PositionColoredTextured.Format;


            //D3DDev.ShowCursor(false);

            DSoundDev = new Microsoft.DirectX.DirectSound.Device();
            if (GameWindow == null)
            {
                DSoundDev.SetCooperativeLevel(GameControl, Microsoft.DirectX.DirectSound.CooperativeLevel.Normal);
            }
            else
            {
                DSoundDev.SetCooperativeLevel(GameWindow, Microsoft.DirectX.DirectSound.CooperativeLevel.Normal);
            }

            DKeyboardDev = new Microsoft.DirectX.DirectInput.Device(Microsoft.DirectX.DirectInput.SystemGuid.Keyboard);
            DKeyboardDev.Acquire();

            DMouseDev = new Microsoft.DirectX.DirectInput.Device(Microsoft.DirectX.DirectInput.SystemGuid.Mouse);
            DMouseDev.Acquire();

            VertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionColoredTextured), 6, D3DDev, Usage.None, CustomVertex.PositionColoredTextured.Format, Pool.Managed);

            D3DDev.SetStreamSource(0, VertexBuffer, 0);
            D3DDev.TextureState[0].AlphaOperation = TextureOperation.Modulate;

            Sprite = new Sprite(D3DDev);

            FontDescription fd = new FontDescription();

            fd.FaceName = "新宋体";
            fd.Height   = -12;
            Font2D      = new Microsoft.DirectX.Direct3D.Font(D3DDev, fd);

            Font3D = new System.Drawing.Font("新宋体", 12);
        }
 public void Draw(D3D.Device device)
 {
     using (D3D.Sprite d3dSprite = new D3D.Sprite(device)) {
         d3dSprite.Begin(D3D.SpriteFlags.AlphaBlend);
         foreach (BasicSprite sprite in sprites) {
             sprite.Draw(d3dSprite);
         }
         d3dSprite.End();
     }
 }
 public void Draw(D3D.Device device)
 {
     using (D3D.Sprite d3dSprite = new D3D.Sprite(device)) {
         d3dSprite.Begin(D3D.SpriteFlags.AlphaBlend);
         foreach (BasicSprite sprite in sprites)
         {
             sprite.Draw(d3dSprite);
         }
         d3dSprite.End();
     }
 }
Example #12
0
 public void Dispose()
 {
     _Graphics = null;
     F         = null;
     _TargetControl.Dispose();
     _TargetControl = null;
     _SpriteBatch.Dispose();
     _SpriteBatch = null;
     _Device.Dispose();
     _Device = null;
 }
Example #13
0
 void IReflectorCreate.OnCreate(Control pc)
 {
     //throw new Exception( "The method or operation is not implemented." );
     DoCreate(pc);
     sprite  = new Direct3D.Sprite(state.graphics);
     texture = Direct3D.TextureLoader.FromFile(
         state.graphics, "c:/ftn3000/etc/images/misc/sky.jpg", 0, 0, 0, 0, Direct3D.Format.Unknown,
         Direct3D.Pool.Managed, Direct3D.Filter.Linear,
         Direct3D.Filter.Linear, 0);
     Run();
     //paused = false;
 }
Example #14
0
 public override void Dispose()
 {
     if (mD3DFont != null)
     {
         mD3DFont.Dispose();
         mD3DFont = null;
     }
     if (mSprite != null)
     {
         mSprite.Dispose();
         mSprite = null;
     }
 }
Example #15
0
        private bool render_image(Microsoft.DirectX.Direct3D.Sprite sprite, Texture texture, Point hot, double fRadian, int nXDest, int nYDest, int nDestWidth, int nDestHeight, int nXSource, int nYSource, int nSourceWidth, int nSourceHeight, int cbAlpha)
        {
            const double M_PI = 3.14159265358979323846;

            if (sprite == null)
            {
                return(false);
            }

            if (fRadian == M_PI)
            {
                float degrees1 = (float)(fRadian * (180 / M_PI));
            }

            float degrees = (float)(fRadian * (180 / M_PI));

            System.Drawing.Rectangle srcRectangle = new System.Drawing.Rectangle(nXSource, nYSource, nSourceWidth, nSourceHeight);
            //Color color = Color.FromArgb( cbAlpha, Color.White );

            sprite.Begin(SpriteFlags.SortTexture | SpriteFlags.AlphaBlend);
            //sprite.Draw(_Texture, srcRectangle, Vector3.Empty, new Vector3(nXDest, nYDest, 0), cbAlpha );

            //_Sprite.Transform = Matrix.Scaling((float)nDestWidth / nSourceWidth, (float)nDestHeight / nSourceHeight, 0.0f);

            //sprite.Transform = Matrix.Translation(-nSourceWidth / 2, -nSourceHeight / 2, 0);
            //sprite.Transform *= Matrix.RotationZ((float)fRadian);
            //sprite.Transform *= Matrix.Translation(nSourceWidth / 2, nSourceHeight / 2, 0);
            //sprite.Transform *= Matrix.Scaling((float)nDestWidth / nSourceWidth, (float)nDestHeight / nSourceHeight, 0.0f);
            //sprite.Transform *= Matrix.Translation(nXDest, nYDest, 0);

            //sprite.Transform = Matrix.Scaling((float)nDestWidth / nSourceWidth, (float)nDestHeight / nSourceHeight, 0.0f);
            //sprite.Transform *= Matrix.Translation(-nDestWidth / 2, -nDestWidth / 2, 0);
            //sprite.Transform = Matrix.RotationZ((float)fRadian);
            //sprite.Transform *= Matrix.Translation(nDestWidth / 2, nDestWidth / 2, 0);
            //sprite.Transform *= Matrix.Translation(nXDest, nYDest, 0);

            sprite.Transform = Matrix.RotationZ((float)fRadian) * Matrix.Scaling((float)nDestWidth / nSourceWidth, (float)nDestHeight / nSourceHeight, 0.0f) * Matrix.Translation(nXDest, nYDest, 0);

            sprite.Draw(texture, srcRectangle, new Vector3((int)hot.x_, (int)hot.y_, 0), new Vector3(0, 0, 0), System.Drawing.Color.FromArgb(cbAlpha, System.Drawing.Color.White).ToArgb());
            //sprite.Draw(texture, srcRectangle, new Vector3(0, 0, 0), new Vector3(0, 0, 0), System.Drawing.Color.FromArgb(cbAlpha, System.Drawing.Color.White).ToArgb());

            //_Sprite.Draw(_Texture, Vector3.Empty, new Vector3(nXDest, nYDest, 0), Color.White.ToArgb());
            sprite.End();

            //sprite.Begin(SpriteFlags.None);
            //sprite.Draw2D(_Texture, Rectangle.Empty, Rectangle.Empty,
            //              new Point(5, 5), Color.White);
            //sprite.End();

            return(true);
        }
Example #16
0
 void D3D_Device_DeviceLost(object sender, EventArgs e)
 {
     if (mD3DFont != null)
     {
         System.Diagnostics.Debug.Print("{0} Disposing of D3DFont object...", DateTime.Now);
         mD3DFont.Dispose();
         mD3DFont = null;
     }
     if (mSprite != null)
     {
         mSprite.Dispose();
         mSprite = null;
     }
 }
Example #17
0
        public override void release()
        {
            if (_Texture != null)
            {
                _Texture.Dispose();
                _Texture = null;
            }

            if (_Sprite != null)
            {
                _Sprite.Dispose();
                _Sprite = null;
            }
        }
Example #18
0
        static void InitializeGraphics()
        {
            PresentParameters presentParams = new PresentParameters();

            presentParams.Windowed             = true;
            presentParams.SwapEffect           = SwapEffect.Discard;
            presentParams.PresentationInterval = PresentInterval.One;

            dGDevice = new DGDevice(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, m_GameWindow, CreateFlags.SoftwareVertexProcessing, presentParams);

            dGDevice.RenderState.ReferenceAlpha = 0;
            dGDevice.RenderState.AlphaFunction  = Compare.NotEqual;

            DXSprite = new D3DSprite(Game.Device);
        }
Example #19
0
        public void DisplayLevel(int level)
        {
            int     characterStart   = 30;
            int     characterSpacing = 15;
            Vector3 displayPosition  =
                new Vector3((float)this.Width / 2 - characterStart, (float)this.Height / 2, 0f);
            int         digit;
            NixieSprite nixie = new NixieSprite(nixiesTileSet);

            //Render the level indicator
            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            device.BeginScene();
            using (D3D.Sprite d3dSprite = new D3D.Sprite(device)) {
                d3dSprite.Begin(D3D.SpriteFlags.AlphaBlend);

                //Show the letter L
                nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.L, displayPosition);

                //Show the letter E
                displayPosition.X -= characterSpacing;
                nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.E, displayPosition);

                //Show the letter V
                displayPosition.X -= characterSpacing;
                nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.V, displayPosition);

                //Show the letter E
                displayPosition.X -= characterSpacing;
                nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.E, displayPosition);

                //Show the letter L
                displayPosition.X -= characterSpacing;
                nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.L, displayPosition);

                displayPosition.X = (float)this.Width / 2 + 40;
                for (int digitCount = 1; digitCount <= maxLevelDigits; digitCount++)
                {
                    digit  = level % 10;
                    level /= 10;
                    nixie.Draw(d3dSprite, (NixieSprite.NixieCharacters)digit, displayPosition);
                    displayPosition.X -= characterSpacing;
                }
                d3dSprite.End();
            }
            device.EndScene();
            device.Present();
            Thread.Sleep(3000); //wait for 3 seconds
        }
Example #20
0
        //public abstract int height();
        //public abstract int string_width(string s);

        public void set_size(Size size)
        {
            size_ = size;

            Device device = Root.instance().render_system().m_D3DDevice;

            if (device == null)
            {
                return;
            }

            System.Drawing.Font gdiFont = new System.Drawing.Font(name_, 10.0f, System.Drawing.FontStyle.Regular);

            d3dFont_ = new Microsoft.DirectX.Direct3D.Font(device, gdiFont);
            sprite_  = new Microsoft.DirectX.Direct3D.Sprite(device);
        }
        public override void OnRenderInterface(Microsoft.DirectX.Direct3D.Sprite overlay)
        {
            base.OnRenderInterface(overlay);

            int i = 0;

            foreach (KeyValuePair <string, MiningOperationInfo> moi in Mines)
            {
                if (moi.Value.CurrentMiningLimit != 0)
                {
                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(overlay, moi.Value.CurrentMiningLimit.ToString(), new Rectangle(130, 40 + i * 20, 70, 20), DrawTextFormat.Right | DrawTextFormat.VerticalCenter, Color.White);
                }
                else
                {
                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(overlay, "survey", new Rectangle(130, 40 + i * 20, 70, 20), DrawTextFormat.Right | DrawTextFormat.VerticalCenter, Color.Red);
                }
                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(overlay, GameEngine.Instance.ItemTemplates[moi.Key].Title, 220, 40 + i * 20, Color.White);

                i++;
            }
        }
Example #22
0
        public void WriteScore(D3D.Device device, int score)
        {
            Rectangle nixiePosition = new Rectangle(nixiesTileSet.XOrigin, nixiesTileSet.YOrigin, nixiesTileSet.ExtentX * 2, nixiesTileSet.ExtentY * 2);
            int       digit;

            using (D3D.Sprite d3dSprite = new D3D.Sprite(device)) {
                d3dSprite.Begin(D3D.SpriteFlags.AlphaBlend);
                for (int digitCount = 1; digitCount <= maxScoreDigits; digitCount++)
                {
                    digit           = score % 10;
                    score          /= 10;
                    nixiePosition.X = nixiesTileSet.XOrigin + (digit % nixiesTileSet.NumberFrameColumns) * nixiesTileSet.ExtentX * 2;
                    nixiePosition.Y = nixiesTileSet.YOrigin; //we know it's only one row
                    Vector3 position = new Vector3((float)this.Width / 2 - digitCount * nixiesTileSet.ExtentX * 2,
                                                   (float)this.Height - 60f, 0f);
                    d3dSprite.Draw(nixiesTileSet.Texture, nixiePosition,
                                   new Vector3(), position, Color.FromArgb(255, 255, 255, 255));
                }
                d3dSprite.End();
            }
        }
Example #23
0
        public virtual void Dispose()
        {
            foreach (Picture picture in m_Pictures)
            {
                picture.Dispose();
            }
            m_Pictures.Clear();

            foreach (Font font in m_Fonts)
            {
                font.Dispose();
            }
            m_Fonts.Clear();

            foreach (Sound sound in m_Sounds)
            {
                sound.Dispose();
            }
            m_Sounds.Clear();

            foreach (Music music in m_Music)
            {
                music.Dispose();
            }
            m_Music.Clear();

            dIDevice.Dispose();
            dIDevice = null;
            dsDevice.Dispose();
            dsDevice = null;
            DXSprite.Dispose();
            DXSprite = null;
            dGDevice.Dispose();
            dGDevice = null;
            m_GameWindow.Dispose();
            m_GameWindow = null;
            m_Disposed   = true;
        }
Example #24
0
 /// <summary>
 /// Forces display of lable if we are hooked
 /// </summary>
 /// <param name="drawArgs"></param>
 /// <param name="sprite"></param>
 /// <param name="projectedPoint"></param>
 /// <param name="color"></param>
 /// <param name="labelRectangles"></param>
 /// <param name="isMouseOver"></param>
 protected override void RenderLabel(DrawArgs drawArgs, Microsoft.DirectX.Direct3D.Sprite sprite, Microsoft.DirectX.Vector3 projectedPoint, int color, System.Collections.Generic.List <System.Drawing.Rectangle> labelRectangles, bool isMouseOver)
 {
     base.RenderLabel(drawArgs, sprite, projectedPoint, color, labelRectangles, (isMouseOver || IsHooked));
 }
        /// <summary>
        /// Initializes the Managed Direct3D Wrapper.
        /// 
        /// This overload is designed for displaying a diferent resolution then the controls size.
        /// </summary>
        /// <param name="renderWindow">Window to render to.</param>
        /// <param name="screenWidth">Width of the screen in pixels.</param>
        /// <param name="screenHeight">Height of the screen in pixels.</param>
        /// <param name="vsync">Should the renderer wait for a vsync before drawing?</param>
        /// <returns>true if successful, false otherwise.</returns>
        public bool InitManagedDirect3D(System.Windows.Forms.Control renderWindow, int screenWidth, int screenHeight, bool vsync)
        {
            try
            {
                // Now  setup our D3D present parameters
                presentParams = new PresentParameters();
                presentParams.BackBufferWidth = screenWidth;
                presentParams.BackBufferHeight = screenHeight;
                //taking out the option for fullscreen mode
                //presentParams.BackBufferFormat = (isWindowed) ? Format.Unknown : Format.R5G6B5;
                presentParams.BackBufferFormat = Format.Unknown;
                presentParams.BackBufferCount = 1;
                presentParams.MultiSample = MultiSampleType.None;
                presentParams.MultiSampleQuality = 0;
                presentParams.SwapEffect = SwapEffect.Copy;// Discard;
                presentParams.DeviceWindow = renderWindow;
                //taking out the option for fullscreen mode
                //presentParams.Windowed = isWindowed;
                presentParams.Windowed = true;
                presentParams.EnableAutoDepthStencil = false;
                presentParams.FullScreenRefreshRateInHz = 0;
                presentParams.PresentationInterval = (vsync) ? PresentInterval.Default : PresentInterval.Immediate;

                // only Create if we haven't done so already
                if(device == null)
                device = new Device(0, DeviceType.Hardware, renderWindow,
                        CreateFlags.HardwareVertexProcessing, presentParams);

                //Create the SwapChain
            lSwapChains.Add(new ManagedSwapChain(device, presentParams));
            }
            catch (Exception)
            {
                DialogResult r = MessageBox.Show("Failed to Create D3D Device", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                return false;
            }

            try
            {
                sprite = new Microsoft.DirectX.Direct3D.Sprite(device);
            }
            catch (Exception)
            {
                DialogResult r = MessageBox.Show("Failed to Create the Sprite object", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                return false;
            }

            try
            {
                line = new Microsoft.DirectX.Direct3D.Line(device);

                line.Antialias = true;
                line.Width = 3.0f;
            }
            catch (Exception)
            {
                DialogResult r = MessageBox.Show("Failed to Create the Line Object", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                return false;
            }

            try
            {
                fontDescription.FaceName = "arial";
                fontDescription.Quality = FontQuality.Default;
                fontDescription.Weight = FontWeight.Bold;

                font = new Microsoft.DirectX.Direct3D.Font(device, fontDescription);

                line.Antialias = true;
                line.Width = 3.0f;
            }
            catch (Exception)
            {
                DialogResult r = MessageBox.Show("Failed to Create the font Object", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                return false;
            }

            return true;
        }
Example #26
0
        void init()
        {
            Microsoft.DirectX.Direct3D.PresentParameters pps = new Microsoft.DirectX.Direct3D.PresentParameters();
            pps.SwapEffect = Microsoft.DirectX.Direct3D.SwapEffect.Discard;
            pps.Windowed = true;
            pps.BackBufferCount = 1;
            pps.PresentationInterval = PresentInterval.One;
            pps.BackBufferFormat = Format.A8R8G8B8;

            if (GameWindow == null)
            {
                //pps.BackBufferWidth = GameControl.Width;
                //pps.BackBufferHeight = GameControl.Height;
                D3DDev = new Microsoft.DirectX.Direct3D.Device(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, GameControl, Microsoft.DirectX.Direct3D.CreateFlags.SoftwareVertexProcessing, pps);
            }
            else
            {
                //pps.BackBufferWidth = GameWindow.Width;
                //pps.BackBufferHeight = GameWindow.Height;
                D3DDev = new Microsoft.DirectX.Direct3D.Device(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, GameWindow, Microsoft.DirectX.Direct3D.CreateFlags.SoftwareVertexProcessing, pps);
            }
            D3DDev.VertexFormat = CustomVertex.PositionColoredTextured.Format;

            //D3DDev.ShowCursor(false);

            DSoundDev = new Microsoft.DirectX.DirectSound.Device();
            if (GameWindow == null)
            {
                DSoundDev.SetCooperativeLevel(GameControl, Microsoft.DirectX.DirectSound.CooperativeLevel.Normal);
            }
            else
            {
                DSoundDev.SetCooperativeLevel(GameWindow, Microsoft.DirectX.DirectSound.CooperativeLevel.Normal);
            }

            DKeyboardDev = new Microsoft.DirectX.DirectInput.Device(Microsoft.DirectX.DirectInput.SystemGuid.Keyboard);
            DKeyboardDev.Acquire();

            DMouseDev = new Microsoft.DirectX.DirectInput.Device(Microsoft.DirectX.DirectInput.SystemGuid.Mouse);
            DMouseDev.Acquire();

            VertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionColoredTextured), 6, D3DDev, Usage.None, CustomVertex.PositionColoredTextured.Format, Pool.Managed);

            D3DDev.SetStreamSource(0, VertexBuffer, 0);
            D3DDev.TextureState[0].AlphaOperation = TextureOperation.Modulate;

            Sprite = new Sprite(D3DDev);

            FontDescription fd = new FontDescription();
            fd.FaceName = "新宋体";
            fd.Height = -12;
            Font2D = new Microsoft.DirectX.Direct3D.Font(D3DDev, fd);

            Font3D = new System.Drawing.Font("新宋体", 12);
        }
        /// <summary>
        /// Initializes the Managed Texture Manager.
        /// </summary>
        /// <param name="device">Direct3D device.</param>
        /// <param name="sprite">Sprite device.</param>
        /// <returns>true if successful, false otherwise.</returns>
        public bool InitManagedTextureManager(Microsoft.DirectX.Direct3D.Device device, Microsoft.DirectX.Direct3D.Sprite sprite)
        {
            this.device = device;
            this.sprite = sprite;
            this.textures = new System.Collections.ArrayList();

            return (device != null && sprite != null);
        }
Example #28
0
        // Direct3D device reset event handler
        void device_DeviceReset(object sender, EventArgs e)
        {
            device.RenderState.ZBufferEnable = true;
            device.RenderState.Lighting = true;
            device.RenderState.CullMode = Cull.Clockwise;

            if (spriteobj == null)
            {
                spriteobj = new Sprite(device);
            }
        }
        public override void OnRenderInterface(Microsoft.DirectX.Direct3D.Sprite Overlay)
        {
            GuiMenu mnu = GameEngine.Instance.GuiMenuModule["factoryMenu"];

            TextureManagerItem it;

            if (BuildQueueIndex != -1 && BuildProgress > -1)
            {
                StoreItem sit = GameEngine.Instance.ItemTemplates[BuildQueue[BuildQueueIndex].ItemId];
                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, sit.Title, new Rectangle(mnu.Location.X, mnu.Location.Y + 40, 200, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.Green);

                if (GameEngine.Instance.GuiTextures.ContainsKey("placeholder"))
                {
                    it = GameEngine.Instance.mainTextures.GetTexture(GameEngine.Instance.GuiTextures["placeholder"].textureIdx);
                    if (it != null && it.Texture != null)
                    {
                        Overlay.Transform = Matrix.Identity;

                        Overlay.Draw(it.Texture, new Rectangle(0, 0, 200, 125), new Vector3(0, 0, 0), new Vector3(mnu.Location.X, mnu.Location.Y + 69, 0), Color.FromArgb(255, 13, 13, 13).ToArgb());
                    }
                }

                if (GameEngine.Instance.GuiTextures.ContainsKey(sit.Picture))
                {
                    it = GameEngine.Instance.mainTextures.GetTexture(GameEngine.Instance.GuiTextures[sit.Picture].textureIdx);
                    if (it != null && it.Texture != null)
                    {
                        Overlay.Transform = Matrix.Identity;

                        Overlay.Draw(it.Texture, new Rectangle(sit.TextureArea.Width * ((BuildProgress * 3) / sit.BuildTime + 1), 0, sit.TextureArea.Width, sit.TextureArea.Height), new Vector3(sit.TextureArea.Width, 0, 0), new Vector3(mnu.Location.X + 200, mnu.Location.Y + 69, 0), Color.White.ToArgb());
                    }
                }
            }

            if (HasAOC)
            {
                if (GameEngine.Instance.GuiTextures.ContainsKey("gameScreen.Production.AOC"))
                {
                    it = GameEngine.Instance.mainTextures.GetTexture(GameEngine.Instance.GuiTextures["gameScreen.Production.AOC"].textureIdx);
                    if (it != null && it.Texture != null)
                    {
                        Overlay.Transform = Matrix.Identity;

                        Overlay.Draw(it.Texture, new Rectangle(0, 0, 305, 58), new Vector3(0, 0, 0), new Vector3(mnu.Location.X + 366, mnu.Location.Y + 350, 0), Color.White.ToArgb());
                    }
                }
                // TODO: Render the real AOC blink
                if (GameEngine.Instance.GuiTextures.ContainsKey("gameScreen.Storage.ItemBlink"))
                {
                    it = GameEngine.Instance.mainTextures.GetTexture(GameEngine.Instance.GuiTextures["gameScreen.Storage.ItemBlink"].textureIdx);
                    if (it != null && it.Texture != null)
                    {
                        Overlay.Transform = Matrix.Identity;

                        Overlay.Draw(it.Texture, new Rectangle(8 + 42 * ((Environment.TickCount / 70) % 10), 8, 7, 4), new Vector3(0, 0, 0), new Vector3(mnu.Location.X + 366 + 58, mnu.Location.Y + 350 + 22, 0), Color.Red.ToArgb());
                        Overlay.Draw(it.Texture, new Rectangle(8 + 42 * ((Environment.TickCount / 70) % 10), 8, 7, 4), new Vector3(0, 0, 0), new Vector3(mnu.Location.X + 366 + 58, mnu.Location.Y + 350 + 21, 0), Color.Red.ToArgb());
                    }
                }
            }
            else
            {
                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, "LEADER", new Rectangle(mnu.Location.X + 364, mnu.Location.Y + 349, 90, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.Red);
                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, "RANK", new Rectangle(mnu.Location.X + 364, mnu.Location.Y + 369, 90, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.Red);
                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, "STAFF", new Rectangle(mnu.Location.X + 364, mnu.Location.Y + 389, 90, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.Red);

                if (ProductionTeam == null)
                {
                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, "None", new Rectangle(mnu.Location.X + 454, mnu.Location.Y + 349, 218, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.White);
                }
                else
                {
                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, ProductionTeam.TeamLeader, new Rectangle(mnu.Location.X + 454, mnu.Location.Y + 349, 218, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.White);
                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, ProductionTeam.GetTeamRank(), new Rectangle(mnu.Location.X + 454, mnu.Location.Y + 369, 218, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.White);
                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, ProductionTeam.TeamSize.ToString(), new Rectangle(mnu.Location.X + 454, mnu.Location.Y + 389, 218, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.White);
                }
            }
        }
Example #30
0
        static void InitializeGraphics()
        {
            PresentParameters presentParams = new PresentParameters();
            presentParams.Windowed = true;
            presentParams.SwapEffect = SwapEffect.Discard;
            presentParams.PresentationInterval = PresentInterval.One;

            dGDevice = new DGDevice(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, m_GameWindow, CreateFlags.SoftwareVertexProcessing, presentParams);

            dGDevice.RenderState.ReferenceAlpha = 0;
            dGDevice.RenderState.AlphaFunction = Compare.NotEqual;

            DXSprite = new D3DSprite(Engine_Game.Device);
        }
Example #31
0
 public Drawer()
 {
     DxSprite = new Microsoft.DirectX.Direct3D.Sprite(D3DDevice.Instance.Device);
     line     = new Line(D3DDevice.Instance.Device);
 }
Example #32
0
 public Drawer2D()
 {
     this.d3dDevice = GuiController.Instance.D3dDevice;
     DxSprite       = new Microsoft.DirectX.Direct3D.Sprite(d3dDevice);
     line           = new Line(d3dDevice);
 }
Example #33
0
 public void Dispose()
 {
     _Graphics = null;
     F = null;
     _TargetControl.Dispose();
     _TargetControl = null;
     _SpriteBatch.Dispose();
     _SpriteBatch = null;
     _Device.Dispose();
     _Device = null;
 }
Example #34
0
 public TgcDrawer2D()
 {
     this.d3dDevice = GuiController.Instance.D3dDevice;
     dxSprite = new Microsoft.DirectX.Direct3D.Sprite(d3dDevice);
 }
Example #35
0
        /// <summary>
        /// Initializes the Managed Direct3D Wrapper.
        /// </summary>
        /// <param name="renderWindow">Window to render to.</param>
        /// <param name="screenWidth">Width of the screen in pixels.</param>
        /// <param name="screenHeight">Height of the screen in pixels.</param>
        /// <param name="isWindowed">Is the application windowed or not (!!ALWAYS PASS true FOR NOW!!).</param>
        /// <param name="vsync">Should the renderer wait for a vsync before drawing?</param>
        /// <returns>true if successful, false otherwise.</returns>
        public bool InitManagedDirect3D(System.Windows.Forms.Control renderWindow, int screenWidth, int screenHeight, bool isWindowed, bool vsync)
        {
            try
            {
                // Now  setup our D3D present parameters
                presentParams = new PresentParameters();
                presentParams.BackBufferWidth           = screenWidth;
                presentParams.BackBufferHeight          = screenHeight;
                presentParams.BackBufferFormat          = (isWindowed) ? Format.Unknown : Format.R5G6B5;
                presentParams.BackBufferCount           = 1;
                presentParams.MultiSample               = MultiSampleType.None;
                presentParams.MultiSampleQuality        = 0;
                presentParams.SwapEffect                = SwapEffect.Copy;// Discard;
                presentParams.DeviceWindow              = renderWindow;
                presentParams.Windowed                  = isWindowed;
                presentParams.EnableAutoDepthStencil    = false;
                presentParams.FullScreenRefreshRateInHz = 0;
                presentParams.PresentationInterval      = (vsync) ? PresentInterval.Default : PresentInterval.Immediate;

                device = new Device(0, DeviceType.Hardware, renderWindow,
                                    CreateFlags.HardwareVertexProcessing, presentParams);
            }
            catch (Exception)
            {
                DialogResult r = MessageBox.Show("Failed to Create D3D Device", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                return(false);
            }

            try
            {
                sprite = new Microsoft.DirectX.Direct3D.Sprite(device);
            }
            catch (Exception)
            {
                DialogResult r = MessageBox.Show("Failed to Create the Sprite object", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                return(false);
            }

            try
            {
                line = new Microsoft.DirectX.Direct3D.Line(device);

                line.Antialias = true;
                line.Width     = 3.0f;
            }
            catch (Exception)
            {
                DialogResult r = MessageBox.Show("Failed to Create the Line Object", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                return(false);
            }

            try
            {
                fontDescription.FaceName = "arial";
                fontDescription.Quality  = FontQuality.Default;
                fontDescription.Weight   = FontWeight.Bold;

                font = new Microsoft.DirectX.Direct3D.Font(device, fontDescription);

                line.Antialias = true;
                line.Width     = 3.0f;
            }
            catch (Exception)
            {
                DialogResult r = MessageBox.Show("Failed to Create the font Object", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                return(false);
            }

            return(true);
        }
        public override void OnRenderInterface(Microsoft.DirectX.Direct3D.Sprite overlay)
        {
            if (mineralList)
            {
                isDescriptionShown = false;
            }
            else
            {
                if (GameEngine.Instance.IsMouseDown)
                {
                    isDescriptionShown = false;
                    curItemId          = "";
                }
            }

            int i = 0;

            Dictionary <string, int> pomst = null;

            if (this.mineralList)
            {
                pomst = this.StoreMaterials;
            }
            else
            {
                pomst = this.StoreItems;
            }

            Dictionary <string, int> required = new Dictionary <string, int>();

            if (curItemId != "" && mineralList)
            {
                for (i = 0; i < GameEngine.Instance.ItemTemplates[curItemId].Resources.Count; i++)
                {
                    required.Add(GameEngine.Instance.ItemTemplates[curItemId].Resources[i].itemId, GameEngine.Instance.ItemTemplates[curItemId].Resources[i].amount);
                }
            }

            int maxCanDo = 200;

            i = 0;
            foreach (KeyValuePair <string, int> si in pomst)
            {
                if (GameEngine.Instance.ItemTemplates[si.Key].Researched)
                {
                    Color col = Color.FromArgb(255, 110, 110, 45);
                    if (required.ContainsKey(si.Key))
                    {
                        if (required[si.Key] <= si.Value)
                        {
                            col = Color.Green;
                        }
                        else
                        {
                            col = Color.Red;
                        }

                        int pom = si.Value / required[si.Key];
                        if (maxCanDo > pom)
                        {
                            maxCanDo = pom;
                        }
                    }

                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(overlay, si.Value.ToString(), new Rectangle(130, 40 + i * 20, 70, 20), DrawTextFormat.Right | DrawTextFormat.VerticalCenter, col);
                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(overlay, GameEngine.Instance.ItemTemplates[si.Key].Title, 220, 40 + i * 20, Color.White);
                    Rectangle rct;
                    rct = GameEngine.Instance.GuiFonts["fntGui"].DXFont.MeasureString(overlay, GameEngine.Instance.ItemTemplates[si.Key].Title, DrawTextFormat.None, Color.White);
                    rct.Offset(220, 40 + i * 20);

                    if (rct.Contains(GameEngine.Instance.MouseCoords))
                    {
                        GameEngine.Instance.CurrentTooltip = GameEngine.Instance.ItemTemplates[si.Key].Title;

                        if (!mineralList && GameEngine.Instance.IsMouseDown)
                        {
                            isDescriptionShown = true;
                            curItemId          = si.Key;
                        }
                    }

                    i++;
                }
            }

            GuiMenu mnu = GameEngine.Instance.GuiMenuModule["miningStoreMenu"];

            Point center = new Point(mnu.Location.X + mnu.TextureArea.Width / 2, mnu.Location.Y + mnu.TextureArea.Height / 2);

            if (mineralList && curItemId != "")
            {
                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(overlay, "Enough Supplies For\r\n" + maxCanDo.ToString() + "x " + GameEngine.Instance.ItemTemplates[curItemId].Title, new Rectangle(mnu.Location.X, mnu.Location.Y, mnu.TextureArea.Width - 140, mnu.TextureArea.Height), DrawTextFormat.Right | DrawTextFormat.Top, Color.Yellow);
            }

            if (isDescriptionShown)
            {
                StoreItem si = GameEngine.Instance.ItemTemplates[curItemId];

                TextureManagerItem it;
                if (GameEngine.Instance.GuiTextures.ContainsKey("gameScreen.Storage.ItemDescription"))
                {
                    it = GameEngine.Instance.mainTextures.GetTexture(GameEngine.Instance.GuiTextures["gameScreen.Storage.ItemDescription"].textureIdx);
                    if (it != null && it.Texture != null)
                    {
                        overlay.Transform = Matrix.Identity;

                        overlay.Draw(it.Texture, new Rectangle(0, 0, 600, 300), new Vector3(300, 150, 0), new Vector3(center.X, center.Y, 0), Color.White.ToArgb());
                    }
                }

                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(overlay, si.Title, new Rectangle(center.X - 270, center.Y - 130, 540, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.White);
                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(overlay, si.Description, new Rectangle(center.X - 270, center.Y - 110, 540, 260), DrawTextFormat.Left | DrawTextFormat.Top, Color.Yellow);

                if (GameEngine.Instance.GuiTextures.ContainsKey(si.Picture))
                {
                    it = GameEngine.Instance.mainTextures.GetTexture(GameEngine.Instance.GuiTextures[si.Picture].textureIdx);
                    if (it != null && it.Texture != null)
                    {
                        overlay.Transform = Matrix.Identity;

                        overlay.Draw(it.Texture, new Rectangle(0, 0, si.TextureArea.Width, si.TextureArea.Height), new Vector3(si.TextureArea.Width, si.TextureArea.Height / 2, 0), new Vector3(center.X + 270, center.Y, 0), Color.White.ToArgb());
                    }
                }
            }
        }
 public void WriteScore(D3D.Device device, int score)
 {
     Rectangle nixiePosition = new Rectangle(nixiesTileSet.XOrigin,nixiesTileSet.YOrigin,nixiesTileSet.ExtentX*2,nixiesTileSet.ExtentY*2);
     int digit;
     using (D3D.Sprite d3dSprite = new D3D.Sprite(device)) {
         d3dSprite.Begin(D3D.SpriteFlags.AlphaBlend);
         for (int digitCount = 1; digitCount <= maxScoreDigits; digitCount++) {
             digit = score % 10;
             score /= 10;
             nixiePosition.X = nixiesTileSet.XOrigin + ( digit % nixiesTileSet.NumberFrameColumns ) * nixiesTileSet.ExtentX*2;
             nixiePosition.Y = nixiesTileSet.YOrigin; //we know it's only one row
             Vector3 position = new Vector3((float)this.Width/2 - digitCount*nixiesTileSet.ExtentX*2,
                 (float)this.Height-60f, 0f);
             d3dSprite.Draw(nixiesTileSet.Texture, nixiePosition,
                 new Vector3(), position, Color.FromArgb(255,255,255,255));
         }
         d3dSprite.End();
     }
 }
Example #38
0
        public virtual void Dispose()
        {
            foreach(Engine_Picture picture in m_Pictures)
                picture.Dispose();
            m_Pictures.Clear();

            foreach(Engine_Font font in m_Fonts)
                font.Dispose();
            m_Fonts.Clear();

            foreach(Engine_Sound sound in m_Sounds)
                sound.Dispose();
            m_Sounds.Clear();

            foreach (Engine_Music music in m_Music)
                music.Dispose();
            m_Music.Clear();

            dIDevice.Dispose();
            dIDevice = null;
            // Kommenter ut disse 2 linjer under "dsDevice..." om du ikke har lydkort
            dsDevice.Dispose();
            dsDevice = null;
            DXSprite.Dispose();
            DXSprite = null;
            dGDevice.Dispose();
            dGDevice = null;
            m_GameWindow.Dispose();
            m_GameWindow = null;
            m_Disposed = true;
        }
        public void DisplayLevel(int level)
        {
            int characterStart = 30;
            int characterSpacing = 15;
            Vector3 displayPosition =
                new Vector3((float)this.Width/2 - characterStart, (float)this.Height/2, 0f);
            int digit;
            NixieSprite nixie = new NixieSprite(nixiesTileSet);

            //Render the level indicator
            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            device.BeginScene();
            using (D3D.Sprite d3dSprite = new D3D.Sprite(device)) {
                d3dSprite.Begin(D3D.SpriteFlags.AlphaBlend);

                //Show the letter L
                nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.L, displayPosition);

                //Show the letter E
                displayPosition.X -= characterSpacing;
                nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.E, displayPosition);

                //Show the letter V
                displayPosition.X -= characterSpacing;
                nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.V, displayPosition);

                //Show the letter E
                displayPosition.X -= characterSpacing;
                nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.E, displayPosition);

                //Show the letter L
                displayPosition.X -= characterSpacing;
                nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.L, displayPosition);

                displayPosition.X = (float)this.Width/2 + 40;
                for (int digitCount = 1; digitCount <= maxLevelDigits; digitCount++) {
                    digit = level % 10;
                    level /= 10;
                    nixie.Draw(d3dSprite, (NixieSprite.NixieCharacters)digit, displayPosition);
                    displayPosition.X -= characterSpacing;
                }
                d3dSprite.End();
            }
            device.EndScene();
            device.Present();
            Thread.Sleep(3000); //wait for 3 seconds
        }
Example #40
0
 public Drawer()
 {
     this.d3dDevice = GuiController.Instance.D3dDevice;
     DxSprite = new Microsoft.DirectX.Direct3D.Sprite(d3dDevice);
     line = new Line(d3dDevice);
 }