Ejemplo n.º 1
0
        public FieldRenderInfo(object field, UpdateFieldType type)
        {
            Field = field;
            Type = type;
            Name = FieldRenderUtil.GetFriendlyName(field);

            FieldRenderUtil.CustomRenderers.TryGetValue(field, out Renderer);
            if (Renderer == null)
            {
                Renderer = FieldRenderUtil.TypeRenderers[(int)Type];
            }

            Index = Convert.ToUInt32(field);
        }
        /// <summary>
        /// Create test game
        /// </summary>
        /// <param name="setWindowsTitle">Set windows title</param>
        /// <param name="windowWidth">Window width</param>
        /// <param name="windowHeight">Window height</param>
        /// <param name="setInitCode">Set init code</param>
        /// <param name="setUpdateCode">Set update code</param>
        /// <param name="setRenderCode">Set render code</param>
        protected TestGame(string setWindowsTitle,
			int windowWidth, int windowHeight,
			RenderHandler setInitCode,
			RenderHandler setUpdateCode,
			RenderHandler setRenderCode)
            : base(setWindowsTitle)
        {
            /*not required
            // Make sure we are in the game directory, unit tests might
            // be executed from another directory and then the content files
            // will not be found!
            Directory.SetCurrentDirectory(Directories.GameBaseDirectory);
             */
            #if !XBOX360
            if (windowWidth > 0 &&
                windowHeight > 0)
            {
                // Update width and height
                this.Window.BeginScreenDeviceChange(false);
                this.Window.EndScreenDeviceChange(
                    this.Window.ScreenDeviceName, windowWidth, windowHeight);
                // Make sure our device is changed too (else the resolution
                // is not set for our 2d rendering).
                this.graphicsManager.PreferredBackBufferWidth = windowWidth;
                this.graphicsManager.PreferredBackBufferHeight = windowHeight;
                this.graphicsManager.ApplyChanges();
            } // if (windowWidth)
            #endif

            //unused, done in constructor:
            //if (String.IsNullOrEmpty(setWindowsTitle) == false)
            //	this.Window.Title = setWindowsTitle;

            //don't show, we got a custom mouse cursor now:
            //this.IsMouseVisible = true;
            #if !XBOX360
            #if DEBUG
            WindowsHelper.ForceForegroundWindow(this.Window.Handle.ToInt32());
            #endif
            #endif
            initCode = setInitCode;
            updateCode = setUpdateCode;
            renderCode = setRenderCode;
        }
Ejemplo n.º 3
0
        public VentanaJuego()
        {
            InitializeComponent();
            //this.Width = w;
            //this.Height = h;
            //pictureBox1.Width = w ;
            //pictureBox1.Height = h;
            //----------Manager--------------------//
            F_M = new FileManager();
            R_M = new RenderManager();
            S_M = new SceneManager();
            PM = new PhisicManager();

            //--------Delegados-------------------//
            S_H = new SceneHandler(S_M.PlayScene);
            R_H = new RenderHandler(R_M.AddData);
            F_H = new FileHandler(F_M.GetImg);

            //---------Inicializacion------------//
            R_M.AddHandlers(S_H, F_H);
            //mapa1.SetFileManager(F_H);
            mapa1 = F_M.CargarMapa("../../Mapas/mapa3.xml", this.Width, this.Height, 32);
            mapa1.IM.left = Keys.A;
            mapa1.IM.right = Keys.D;
            mapa1.IM.up = Keys.W;
            mapa1.IM.down = Keys.S;
            mapa1.Draw(R_H);
            R_M.Sorting();
            //--------Timer--------------------//
            //Thread mov = new Thread(Caminar);
            //Thread col = new Thread(Colicion);
            //mov.Start();
            timer1.Start();
            //col.Start();
            mapa1.FraccPantalla(pictureBox1.Width, pictureBox1.Height);
            mapa1.CentrarJugador();
            //----------Sonido------------------//
            //mp = new MP3Player();
            //mp.Open(F_M.GetAud_Path("Correr"));
            //mp.Play();

            pictureBox1.Refresh();
        }
Ejemplo n.º 4
0
 protected virtual bool StartDragging(IDragData dragData, DragOperationsMask mask, int x, int y)
 {
     return(RenderHandler?.StartDragging(dragData, mask, x, y) ?? false);
 }
Ejemplo n.º 5
0
 public void Draw(RenderHandler R_H)
 {
     foreach(Elemento a in Ele)
     {
         a.Draw(R_H);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Dispose of resources (IDisposable implementation)
        /// </summary>
        /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && !disposed)
            {
                lock (renderSyncObject)
                {
                    render = null;

                    lock (sharedSyncObject)
                    {
                        if (sharedD2DFactory != null && d2DFactory == sharedD2DFactory)
                            sharedRefCount--;

                        if (d2DFactory != null && d2DFactory != sharedD2DFactory)
                            d2DFactory.Dispose();
                        d2DFactory = null;

                        if (dwriteFactory != null && dwriteFactory != sharedDwriteFactory)
                            dwriteFactory.Dispose();
                        dwriteFactory = null;

                        if (wicFactory != null && wicFactory != sharedWicFactory)
                            wicFactory.Dispose();
                        wicFactory = null;

                        if (sharedRefCount == 0)
                        {
                            if (sharedD2DFactory != null)
                                sharedD2DFactory.Dispose();
                            sharedD2DFactory = null;

                            if (sharedDwriteFactory != null)
                                sharedDwriteFactory.Dispose();
                            sharedDwriteFactory = null;

                            if (sharedWicFactory != null)
                                sharedWicFactory.Dispose();
                            sharedWicFactory = null;
                        }
                    }

                    foreach (DrawingShape shape in drawingShapes)
                    {
                        shape.Dispose();
                    }

                    if (bitmap != null)
                        bitmap.Dispose();
                    bitmap = null;

                    if (dcRenderTarget != null)
                        dcRenderTarget.Dispose();
                    dcRenderTarget = null;
                    if (bitmapRenderTarget != null)
                        bitmapRenderTarget.Dispose();
                    bitmapRenderTarget = null;
                    if (hwndRenderTarget != null)
                        hwndRenderTarget.Dispose();
                    hwndRenderTarget = null;


                    disposed = true;
                }
            }
            base.Dispose(disposing);
        }
Ejemplo n.º 7
0
        public virtual void Render(ref Matrix worldMatrix, String techniqueName, 
            RenderHandler renderDelegate)
        {
            if (techniqueName == null)
                throw new GoblinException("techniqueName is null");
            if (renderDelegate == null)
                throw new GoblinException("renderDelegate is null");

            world.SetValue(worldMatrix);
            // Start shader
            effect.CurrentTechnique = effect.Techniques[techniqueName];

            // Render all passes (usually just one)
            //foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            for (int num = 0; num < effect.CurrentTechnique.Passes.Count; num++)
            {
                EffectPass pass = effect.CurrentTechnique.Passes[num];

                pass.Apply();
                renderDelegate();
            }

        }
Ejemplo n.º 8
0
 public void DoAction(string s, RenderHandler R_H)
 {
     Draw(R_H);
 }
Ejemplo n.º 9
0
        private void SetRenderMode(RenderModes rm)
        {
            lock (renderSyncObject)
            {
                renderMode = rm;
                if (!IsInitialized && !isInitializing)
                {
                    return;
                }

                //clean up objects that will be invalid after RenderTarget change
                if (dcRenderTarget != null)
                {
                    dcRenderTarget.Dispose();
                    dcRenderTarget = null;
                }
                if (hwndRenderTarget != null)
                {
                    hwndRenderTarget.Dispose();
                    hwndRenderTarget = null;
                }
                if (bitmapRenderTarget != null)
                {
                    bitmapRenderTarget.Dispose();
                    bitmapRenderTarget = null;
                }
                peelings.Clear();
                bitmap = null; //the bitmap created in dc render target can't be used in hwnd render target

                // Create the screen render target
                var size  = new SizeU((uint)ClientSize.Width, (uint)ClientSize.Height);
                var props = new RenderTargetProperties
                {
                    PixelFormat = new PixelFormat(
                        Format.B8G8R8A8UNorm,
                        AlphaMode.Ignore),
                    Usage = RenderTargetUsages.GdiCompatible
                };

                if (renderMode == RenderModes.DCRenderTarget || renderMode == RenderModes.BitmapRenderTargetOnPaint)
                {
                    dcRenderTarget = d2DFactory.CreateDCRenderTarget(props);
                    if (renderMode == RenderModes.BitmapRenderTargetOnPaint)
                    {
                        bitmapRenderTarget =
                            dcRenderTarget.CreateCompatibleRenderTarget(
                                CompatibleRenderTargetOptions.GdiCompatible,
                                new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.SizeF(ClientSize.Width, ClientSize.Height));
                    }
                    render = null;
                }
                else
                {
                    hwndRenderTarget = d2DFactory.CreateHwndRenderTarget(
                        props,
                        new HwndRenderTargetProperties(Handle, size, Microsoft.WindowsAPICodePack.DirectX.Direct2D1.PresentOptions.RetainContents));
                    if (renderMode == RenderModes.BitmapRenderTargetRealTime)
                    {
                        bitmapRenderTarget =
                            hwndRenderTarget.CreateCompatibleRenderTarget(
                                CompatibleRenderTargetOptions.GdiCompatible,
                                new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.SizeF(ClientSize.Width, ClientSize.Height));
                    }
                    render = RenderSceneInBackground;
                }

                //move all shapes to new rendertarget and refresh
                foreach (var shape in drawingShapes)
                {
                    shape.Bitmap       = Bitmap;
                    shape.RenderTarget = RenderTarget;
                }
                RefreshAll();
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Called when the browser's cursor has changed. .
 /// </summary>
 /// <param name="cursor">If type is Custom then customCursorInfo will be populated with the custom cursor information</param>
 /// <param name="type">cursor type</param>
 /// <param name="customCursorInfo">custom cursor Information</param>
 void IRenderWebBrowser.OnCursorChange(IntPtr cursor, CursorType type, CursorInfo customCursorInfo)
 {
     RenderHandler?.OnCursorChange(cursor, type, customCursorInfo);
 }
        /// <summary>
        /// Start
        /// </summary>
        /// <param name="initCode">Init code</param>
        /// <param name="renderCode">Render code</param>
        public static void Start(
			RenderHandler initCode, RenderHandler renderCode)
        {
            Start("UnitTest", initCode, null, renderCode);
        }
Ejemplo n.º 12
0
 protected virtual void OnImeCompositionRangeChanged(Range selectedRange, Rect[] characterBounds)
 {
     RenderHandler?.OnImeCompositionRangeChanged(selectedRange, characterBounds);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Called when an element has been rendered to the shared texture handle.
 /// This method is only called when <see cref="IWindowInfo.SharedTextureEnabled"/> is set to true
 /// </summary>
 /// <param name="type">indicates whether the element is the view or the popup widget.</param>
 /// <param name="dirtyRect">contains the set of rectangles in pixel coordinates that need to be repainted</param>
 /// <param name="sharedHandle">is the handle for a D3D11 Texture2D that can be accessed via ID3D11Device using the OpenSharedResource method.</param>
 void IRenderWebBrowser.OnAcceleratedPaint(PaintElementType type, Rect dirtyRect, IntPtr sharedHandle)
 {
     RenderHandler?.OnAcceleratedPaint(type, dirtyRect, sharedHandle);
 }
Ejemplo n.º 14
0
 protected virtual void OnPopupSize(Rect rect)
 {
     RenderHandler?.OnPopupSize(rect);
 }
Ejemplo n.º 15
0
 protected virtual void OnPopupShow(bool show)
 {
     RenderHandler?.OnPopupShow(show);
 }
Ejemplo n.º 16
0
 protected virtual void UpdateDragCursor(DragOperationsMask operation)
 {
     RenderHandler?.UpdateDragCursor(operation);
 }
        /// <summary>
        /// Create test game
        /// </summary>
        /// <param name="setWindowsTitle">Set windows title</param>
        /// <param name="setInitCode">Set init code</param>
        /// <param name="setUpdateCode">Set update code</param>
        /// <param name="setRenderCode">Set render code</param>
        protected TestGame(string setWindowsTitle,
			RenderHandler setInitCode,
			RenderHandler setUpdateCode,
			RenderHandler setRenderCode)
            : this(setWindowsTitle, -1, -1,
			setInitCode, setUpdateCode, setRenderCode)
        {
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Starts dragging.
 /// </summary>
 /// <param name="dragData">The drag data.</param>
 /// <param name="mask">The mask.</param>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 bool IRenderWebBrowser.StartDragging(IDragData dragData, DragOperationsMask mask, int x, int y)
 {
     return(RenderHandler?.StartDragging(dragData, mask, x, y) ?? false);
 }
        /// <summary>
        /// Start
        /// </summary>
        /// <param name="testName">Test name</param>
        /// <param name="initCode">Init code</param>
        /// <param name="renderCode">Render code</param>
        public static void Start(string testName,
			RenderHandler initCode, RenderHandler renderCode)
        {
            Start(testName, initCode, null, renderCode);
        }
Ejemplo n.º 20
0
 void IRenderWebBrowser.UpdateDragCursor(DragOperationsMask operation)
 {
     RenderHandler?.UpdateDragCursor(operation);
 }
Ejemplo n.º 21
0
 protected virtual void OnPaint(PaintElementType type, Rect dirtyRect, IntPtr buffer, int width, int height)
 {
     RenderHandler?.OnPaint(type, dirtyRect, buffer, width, height);
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Sets the popup is open.
 /// </summary>
 /// <param name="show">if set to <c>true</c> [show].</param>
 void IRenderWebBrowser.OnPopupShow(bool show)
 {
     RenderHandler?.OnPopupShow(show);
 }
Ejemplo n.º 23
0
		/// <summary>
		/// The triangle functions can check backEnd.currentSpace != surf->space
		/// to see if they need to perform any new matrix setup.  The modelview
		/// matrix will already have been loaded, and backEnd.currentSpace will
		/// be updated after the triangle function completes.
		/// </summary>
		/// <param name="surfaces"></param>
		/// <param name="handler"></param>
		private void RenderDrawSurfaceListWithFunction(DrawSurface[] surfaces, RenderHandler handler)
		{
			int count = surfaces.Length;

			for(int i = 0; i < count; i++)
			{
				DrawSurface surface = surfaces[i];

				// change the matrix if needed
				if(surface.Space != _currentSpace)
				{
					_effect.View = surface.Space.ModelViewMatrix;
				}

				if(surface.Space.WeaponDepthHack == true)
				{
					idConsole.Warning("TODO: RB_EnterWeaponDepthHack();");
				}

				if(surface.Space.ModelDepthHack != 0.0f)
				{
					idConsole.Warning("TODO: RB_EnterModelDepthHack( drawSurf->space->modelDepthHack );");
				}

				// change the scissor if needed
				if((idE.CvarSystem.GetBool("r_useScissor") == true) && (_currentScissor != surface.ScissorRectangle))
				{
					_currentScissor = surface.ScissorRectangle;

					_graphicsDevice.ScissorRectangle = new Rectangle(
						_viewDef.ViewPort.X1 + _currentScissor.X1,
						_viewDef.ViewPort.Y1 + _currentScissor.Y1,
						_currentScissor.X2 + 1 - _currentScissor.X1,
						_currentScissor.Y2 + 1 - _currentScissor.Y1);
				}

				// render it
				handler(surface);

				if((surface.Space.WeaponDepthHack == true) || (surface.Space.ModelDepthHack != 0.0f))
				{
					idConsole.Warning("TODO: RB_LeaveDepthHack();");
				}

				_currentSpace = surface.Space;
			}
		}
Ejemplo n.º 24
0
 /// <summary>
 /// Called when the browser wants to move or resize the popup widget.
 /// </summary>
 /// <param name="rect">contains the new location and size in view coordinates. </param>
 void IRenderWebBrowser.OnPopupSize(Rect rect)
 {
     RenderHandler?.OnPopupSize(rect);
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Stop rendering if removed from a parent control
 /// </summary>
 /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
 protected override void OnParentChanged(EventArgs e)
 {
     lock (renderSyncObject)
     {
         if (Parent == null)
             render = null;
     }
     base.OnParentChanged(e);
 }
Ejemplo n.º 26
0
        public override void Render(ref Matrix worldMatrix, string techniqueName,
            RenderHandler renderDelegate)
        {
            viewProj.SetValue(State.ViewProjectionMatrix);
            viewInverse.SetValue(State.ViewInverseMatrix);

            if (techniqueName.Length == 0)
                techniqueName = "NormalMapOnly";

            base.Render(ref worldMatrix, techniqueName, renderDelegate);
        }
Ejemplo n.º 27
0
        private void SetRenderMode(RenderModes rm)
        {
            lock (renderSyncObject)
            {
                renderMode = rm;
                if (!IsInitialized && !isInitializing)
                    return;

                //clean up objects that will be invalid after RenderTarget change
                if (dcRenderTarget != null)
                {
                    dcRenderTarget.Dispose();
                    dcRenderTarget = null;
                }
                if (hwndRenderTarget != null)
                {
                    hwndRenderTarget.Dispose();
                    hwndRenderTarget = null;
                }
                if (bitmapRenderTarget != null)
                {
                    bitmapRenderTarget.Dispose();
                    bitmapRenderTarget = null;
                }
                peelings.Clear();
                bitmap = null; //the bitmap created in dc render target can't be used in hwnd render target

                // Create the screen render target
                var size = new SizeU((uint)ClientSize.Width, (uint)ClientSize.Height);
                var props = new RenderTargetProperties
                {
                    PixelFormat = new PixelFormat(
                        Format.B8G8R8A8UNorm,
                        AlphaMode.Ignore),
                    Usage = RenderTargetUsages.GdiCompatible
                };

                if (renderMode == RenderModes.DCRenderTarget || renderMode == RenderModes.BitmapRenderTargetOnPaint)
                {
                    dcRenderTarget = d2DFactory.CreateDCRenderTarget(props);
                    if (renderMode == RenderModes.BitmapRenderTargetOnPaint)
                    {
                        bitmapRenderTarget =
                            dcRenderTarget.CreateCompatibleRenderTarget(
                            CompatibleRenderTargetOptions.GdiCompatible,
                            new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.SizeF(ClientSize.Width, ClientSize.Height));
                    }
                    render = null;
                }
                else
                {
                    hwndRenderTarget = d2DFactory.CreateHwndRenderTarget(
                        props,
                        new HwndRenderTargetProperties(Handle, size, Microsoft.WindowsAPICodePack.DirectX.Direct2D1.PresentOptions.RetainContents));
                    if (renderMode == RenderModes.BitmapRenderTargetRealTime)
                    {
                        bitmapRenderTarget =
                            hwndRenderTarget.CreateCompatibleRenderTarget(
                            CompatibleRenderTargetOptions.GdiCompatible,
                            new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.SizeF(ClientSize.Width, ClientSize.Height));
                    }
                    render = RenderSceneInBackground;
                }

                //move all shapes to new rendertarget and refresh
                foreach (var shape in drawingShapes)
                {
                    shape.Bitmap = Bitmap;
                    shape.RenderTarget = RenderTarget;
                }
                RefreshAll();
            }
        }
Ejemplo n.º 28
0
        private void DoRendering30(RenderHandler renderDelegate, List<LightSource> lightSources)
        {
            string passName;
            if (lightSources.Count == 0)
            {
                return;
            }
            else
            {
                passName = "Multiple" + GetPassName(lightSources[0].Type);
            }
            for (int passCount = 0; passCount < (((lightSources.Count - 1) / maxNumLightsPerPass) + 1); passCount++)
            {

                int count = 0;
                for (int l = 0; l < maxNumLightsPerPass; l++)
                {
                    int lightIndex = (passCount * maxNumLightsPerPass) + l;
                    if (lightIndex >= lightSources.Count)
                    {
                        break;
                    }

                    SetUpLightSource(lightSources[lightIndex], l);
                    count++;
                }
               
                numberOfLights.SetValue(count);

                effect.CurrentTechnique.Passes[passName].Apply();
                renderDelegate();
            }
        }
Ejemplo n.º 29
0
 void IRenderWebBrowser.OnImeCompositionRangeChanged(Range selectedRange, Rect[] characterBounds)
 {
     RenderHandler?.OnImeCompositionRangeChanged(selectedRange, characterBounds);
 }
Ejemplo n.º 30
0
 protected virtual void OnCursorChange(IntPtr cursor, CursorType type, CursorInfo customCursorInfo)
 {
     RenderHandler?.OnCursorChange(cursor, type, customCursorInfo);
 }
Ejemplo n.º 31
0
        public override void Render(ref Matrix worldMatrix, string techniqueName, RenderHandler renderDelegate)
        {
            if (renderDelegate == null)
                throw new GoblinException("renderDelegate is null");

            world.SetValue(worldMatrix);
            viewProj.SetValue(State.ViewProjectionMatrix);
            worldForNormal.SetValue(Matrix.Transpose(Matrix.Invert(worldMatrix)));

            // Start shader
            effect.CurrentTechnique = effect.Techniques[defaultTechnique];

            {
                BlendState origBlendState = State.Device.BlendState;
                DepthStencilState origDepthState = State.Device.DepthStencilState;

                State.Device.DepthStencilState = depthState;
                State.Device.BlendState = BlendState.Opaque;
                effect.CurrentTechnique.Passes["Ambient"].Apply();
                renderDelegate();
                State.Device.BlendState = blendState;

                State.Device.DepthStencilState = depthState2;

                if (is_3_0)
                {
                    DoRendering30(renderDelegate, dirLightSources);
                    DoRendering30(renderDelegate, pointLightSources);
                    DoRendering30(renderDelegate, spotLightSources);
                }
                else
                {
                    DoRendering20(renderDelegate, dirLightSources);
                    DoRendering20(renderDelegate, pointLightSources);
                    DoRendering20(renderDelegate, spotLightSources);
                }

                State.Device.BlendState = origBlendState;
                State.Device.DepthStencilState = origDepthState;
            }
        }
Ejemplo n.º 32
0
 void IRenderWebBrowser.OnVirtualKeyboardRequested(IBrowser browser, TextInputMode inputMode)
 {
     RenderHandler?.OnVirtualKeyboardRequested(browser, inputMode);
 }
Ejemplo n.º 33
0
 private void DoRendering20(RenderHandler renderDelegate, List<LightSource> lightSources)
 {
     string passName;
     if (lightSources.Count == 0)
     {
         return;
     }
     else
     {
         passName = "Single" + GetPassName(lightSources[0].Type);
     }
     for (int passCount = 0; passCount < lightSources.Count; passCount++)
     {
         SetUpSingleLightSource(lightSources[passCount]);
         effect.CurrentTechnique.Passes[passName].Apply();
         renderDelegate();
     }
 }
Ejemplo n.º 34
0
 /// <summary>
 /// Gets the screen information (scale factor).
 /// </summary>
 /// <returns>ScreenInfo.</returns>
 protected virtual ScreenInfo?GetScreenInfo()
 {
     return(RenderHandler?.GetScreenInfo());
 }
Ejemplo n.º 35
0
 public virtual void Draw(RenderHandler R_H)
 {
     _Update up = new _Update(this.Update);
     R_H(im, rec, null, profundidad,up);
 }
Ejemplo n.º 36
0
 /// <summary>
 /// Gets the view rect (width, height)
 /// </summary>
 /// <returns>ViewRect.</returns>
 protected virtual Rect?GetViewRect()
 {
     return(RenderHandler?.GetViewRect());
 }
        /// <summary>
        /// Start
        /// </summary>
        /// <param name="testName">Test name</param>
        /// <param name="initCode">Init code</param>
        /// <param name="updateCode">Update code</param>
        /// <param name="renderCode">Render code</param>
        public static void Start(string testName,
			RenderHandler initCode,
			RenderHandler updateCode,
			RenderHandler renderCode)
        {
            using (TestGame game = new TestGame(
                testName, initCode, updateCode, renderCode))
            {
                game.Run();
            } // using (game)
        }
Ejemplo n.º 38
0
        public void Render(ref Matrix worldMatrix, string techniqueName, RenderHandler renderDelegate)
        {
            BasicEffect effect = (internalEffect != null) ? internalEffect : basicEffect;
            effect.View = State.ViewMatrix;
            effect.Projection = State.ProjectionMatrix;
            effect.World = worldMatrix;

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                renderDelegate();
            }
        }
        /// <summary>
        /// Start
        /// </summary>
        /// <param name="testName">Test name</param>
        /// <param name="windowWidth">Window width</param>
        /// <param name="windowHeight">Window height</param>
        /// <param name="initCode">Init code</param>
        /// <param name="renderCode">Render code</param>
        public static void Start(string testName,
			int windowWidth, int windowHeight,
			RenderHandler initCode, RenderHandler renderCode)
        {
            Start(testName, windowWidth, windowHeight, initCode, null, renderCode);
        }
Ejemplo n.º 40
0
        public override void Render(ref Matrix worldMatrix, string techniqueName, RenderHandler renderDelegate)
        {
            if (techniqueName == null)
                throw new GoblinException("techniqueName is null");
            if (renderDelegate == null)
                throw new GoblinException("renderDelegate is null");

            world.SetValue(worldMatrix);
            view.SetValue(State.ViewMatrix);
            projection.SetValue(State.ProjectionMatrix);
            viewportScale.SetValue(new Vector2(0.5f / State.Device.Viewport.AspectRatio, -0.5f));
            // Start shader
            effect.CurrentTechnique = effect.Techniques[techniqueName];

            // Render all passes (usually just one)
            //foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                renderDelegate();
            }

        }
 /// <summary>
 /// Start
 /// </summary>
 /// <param name="renderCode">Render code</param>
 public static void Start(RenderHandler renderCode)
 {
     Start(null, renderCode);
 }
Ejemplo n.º 42
0
        public override void Render(ref Matrix worldMatrix, string techniqueName, 
            RenderHandler renderDelegate)
        {
            worldInverseTranspose.SetValue(Matrix.Transpose(Matrix.Invert(worldMatrix)));
            worldViewProj.SetValue(worldMatrix * State.ViewProjectionMatrix);
            viewInverse.SetValue(Matrix.Invert(State.ViewMatrix));

            base.Render(ref worldMatrix, "Glow", renderDelegate);
        }
Ejemplo n.º 43
0
        public virtual void Render(ref Matrix worldMatrix, String techniqueName, 
            RenderHandler renderDelegate)
        {
            if (String.IsNullOrEmpty(techniqueName))
                techniqueName = "DrawWithShadowMap";
            if (renderDelegate == null)
                throw new GoblinException("renderDelegate is null");

            State.Device.SamplerStates[1] = SamplerState.LinearWrap;
            State.Device.SamplerStates[2] = SamplerState.PointClamp;

            // Start shader
            effect.CurrentTechnique = effect.Techniques[techniqueName];

            world.SetValue(worldMatrix);
            viewProj.SetValue(State.ViewProjectionMatrix);
            castShadows.SetValue(lights[LightIndex].CastShadows);
            isOccluder.SetValue(IsOccluder);

            firstPass.SetValue(LastLayer == null);
            if (LastLayer != null)
                lastLayer.SetValue(LastLayer);

            if (ShadowLightIndex >= 0)
            {
                if (this.Attribute == ShadowAttribute.ReceiveCast)
                    shadowsOnly.SetValue(ShadowMap.OccluderRenderTargets[ShadowLightIndex]);
                else if (this.Attribute == ShadowAttribute.ReceiveOnly)
                    shadowsOnly.SetValue(ShadowMap.ShadowRenderTargets[ShadowLightIndex]);
            }

            if (!IsOccluder)
            {
                lightViewProj.SetValue(lights[LightIndex].LightViewProjection);
                lightType.SetValue((int)lights[LightIndex].LightSource.Type);

                diffuseLightColor.SetValue(lights[LightIndex].LightSource.Diffuse);
                specularLightColor.SetValue(lights[LightIndex].LightSource.Specular);
                ambientLightColor.SetValue(lights[LightIndex].AmbientLightColor);

                if (lights[LightIndex].LightSource.Type != LightType.Directional)
                {
                    lightPosition.SetValue(lights[LightIndex].LightSource.TransformedPosition);

                    atten0.SetValue(lights[LightIndex].LightSource.Attenuation0);
                    atten1.SetValue(lights[LightIndex].LightSource.Attenuation1);
                    atten2.SetValue(lights[LightIndex].LightSource.Attenuation2);
                }
                else
                    lightDirection.SetValue(-lights[LightIndex].LightSource.TransformedDirection);
                if (lights[LightIndex].LightSource.Type == LightType.SpotLight)
                {
                    lightConeAngle.SetValue(lights[LightIndex].LightSource.OuterConeAngle);
                    lightDecay.SetValue(lights[LightIndex].LightSource.Falloff);
                    lightDirection.SetValue(lights[LightIndex].LightSource.TransformedDirection);
                }
            }

            for (int num = 0; num < effect.CurrentTechnique.Passes.Count; num++)
            {
                EffectPass pass = effect.CurrentTechnique.Passes[num];

                pass.Apply();
                renderDelegate();
            }
        }
Ejemplo n.º 44
0
 public override void Draw(RenderHandler R_H)
 {
     _Update up = new _Update(this.Update);
     R_H(im, rec, ani, profundidad, up);
 }
Ejemplo n.º 45
0
 public override void Draw(RenderHandler R_H)
 {
     base.Draw(R_H);
 }
Ejemplo n.º 46
0
        public void ComputeShadow(ref Matrix mat, RenderHandler renderHandler)
        {
            world.SetValue(mat);

            for (int num = 0; num < shadowEffect.CurrentTechnique.Passes.Count; num++)
            {
                EffectPass pass = shadowEffect.CurrentTechnique.Passes[num];

                pass.Apply();
                renderHandler();
            }
        }
Ejemplo n.º 47
0
        public void Render(ref Matrix worldMatrix, string techniqueName, RenderHandler renderDelegate)
        {
            alphaEffect.View = State.ViewMatrix;
            alphaEffect.Projection = State.ProjectionMatrix;
            alphaEffect.World = worldMatrix;

            foreach (EffectPass pass in alphaEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                renderDelegate();
            }
        }
Ejemplo n.º 48
0
        /// <summary>
        /// Dispose of resources (IDisposable implementation)
        /// </summary>
        /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && !disposed)
            {
                lock (renderSyncObject)
                {
                    render = null;

                    lock (sharedSyncObject)
                    {
                        if (sharedD2DFactory != null && d2DFactory == sharedD2DFactory)
                        {
                            sharedRefCount--;
                        }

                        if (d2DFactory != null && d2DFactory != sharedD2DFactory)
                        {
                            d2DFactory.Dispose();
                        }
                        d2DFactory = null;

                        if (dwriteFactory != null && dwriteFactory != sharedDwriteFactory)
                        {
                            dwriteFactory.Dispose();
                        }
                        dwriteFactory = null;

                        if (wicFactory != null && wicFactory != sharedWicFactory)
                        {
                            wicFactory.Dispose();
                        }
                        wicFactory = null;

                        if (sharedRefCount == 0)
                        {
                            if (sharedD2DFactory != null)
                            {
                                sharedD2DFactory.Dispose();
                            }
                            sharedD2DFactory = null;

                            if (sharedDwriteFactory != null)
                            {
                                sharedDwriteFactory.Dispose();
                            }
                            sharedDwriteFactory = null;

                            if (sharedWicFactory != null)
                            {
                                sharedWicFactory.Dispose();
                            }
                            sharedWicFactory = null;
                        }
                    }

                    foreach (DrawingShape shape in drawingShapes)
                    {
                        shape.Dispose();
                    }

                    if (bitmap != null)
                    {
                        bitmap.Dispose();
                    }
                    bitmap = null;

                    if (dcRenderTarget != null)
                    {
                        dcRenderTarget.Dispose();
                    }
                    dcRenderTarget = null;
                    if (bitmapRenderTarget != null)
                    {
                        bitmapRenderTarget.Dispose();
                    }
                    bitmapRenderTarget = null;
                    if (hwndRenderTarget != null)
                    {
                        hwndRenderTarget.Dispose();
                    }
                    hwndRenderTarget = null;


                    disposed = true;
                }
            }
            base.Dispose(disposing);
        }