Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Offline CARUFO  
#1 Posted : Saturday, November 19, 2011 12:40:44 AM(UTC)
CARUFO

Joined: 8/21/2011(UTC)
Posts: 37

Was thanked: 1 time(s) in 1 post(s)
I found a very big bug:
I Draw a Backgroundimage (Material2dColored) in DE 0.9.0 and all works fine.
But in DE 0.9.1 are the Draw positions very buggie:Draw with Rectangle.One, and see nothing. When i change the position its the same problem.
But an other Material2dColored works fine, for example the player.
I hope this helps.

Wanna join the discussion?! Login to your forum accountregister a new account. Or Connect via Facebook Twitter Google

Offline Benjamin  
#2 Posted : Saturday, November 19, 2011 2:03:12 AM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Thanks for the report, will fix asap. Changed some major stuff on rendering the last 2 days, so something could have slipped in there ..
Offline vickfl  
#3 Posted : Saturday, November 19, 2011 7:26:14 PM(UTC)
vickfl

Joined: 10/7/2011(UTC)
Posts: 26
Location: Lübeck, SH, Germany

Thanks: 4 times
Was thanked: 2 time(s) in 2 post(s)
Can confirm this. Material2DColored is drawn in the wrong position, Material2D works just fine. Like above, the project was ported "as-is" to DE 0.9.1.
Offline Benjamin  
#4 Posted : Sunday, November 20, 2011 1:15:12 AM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Hi. I am unable to reproduce this bug. I tested it now with a bunch of unit tests in v0.9.1, but everything was alright. I reverted to yesterdays public beta and tried the following unit test, which works fine as well. Can you guys point me in the right direction when this actually does occur? Also make sure that you use the Dlls from v0.9.1 and have no warnings in the log.

Code:

		#region DrawDefaultMaterialColoredFullscreen
		/// <summary>
		/// Draw default material with color on fullscreen. Testing bug #4481
		/// </summary>
		[Test]
		public static void DrawDefaultMaterialColoredFullscreen()
		{
			Material2DColored background = new Material2DColored(
				//Color.Red);
				"DeltaIcon");
			Application.Start(delegate
			{
				background.Draw(Rectangle.One);
			});
		}
		#endregion
Offline vickfl  
#5 Posted : Sunday, November 20, 2011 2:49:15 PM(UTC)
vickfl

Joined: 10/7/2011(UTC)
Posts: 26
Location: L&#252;beck, SH, Germany

Thanks: 4 times
Was thanked: 2 time(s) in 2 post(s)
Well, its pretty weird: If I create a new Project everything works just fine! It only occurs on my ported project. Here is the rendering code:
Code:

public override void Render()
        {
            base.Render();
            //We need to this manually
            WorldPosition = _body.Position;
            WorldPosition2D = WorldPosition.ToPoint();
            //Draw stuff
            _textureRaw.Draw(new Rectangle(_body.Position2D - _textureSize / 2), _textureSize));
#if DEBUG
            _body.DrawDebug();
#endif
        }

and this is the result:
UserPostedImage
Positions are correct:
UserPostedImage

On the picture only the bricks are drawn using Material2DColored and only those do not fit the "physical" locations. I have no clue why. Is it possible that there was something changed on how the positions are processed? For example in Screenspace class or something? HTere must be an y-value added somewhere Mad

The only warning I get is that the UIScreen for the next Screen is not available, but I do not think that is related to this screen.

Hopes this points you in a specific direction. I am sorry that I do not have further Information, it's just weird :/

Edited by user Sunday, November 20, 2011 2:51:03 PM(UTC)  | Reason: Not specified

Offline Benjamin  
#6 Posted : Sunday, November 20, 2011 3:01:35 PM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
It seems like you are experiencing the resize bug we had a week ago, but it does not make much sense because it is fixed (some other games had similar issues, once you resize your window everything fits again).

You can check out the fix in Delta.Graphics.OpenTK (see OpenTKGraphics constructor). You probably still have the v0.9.0 version of that dll in your executable path and it is not replaced automatically for some reason. Please try to delete your complete \bin\Debug directory including all dlls to force an update.

Another thing I could think of is that your project still references v0.9.0 assemblies (which should not matter if you have overwritten them). Try to reference the assemblies again (or recreate a project). If this is not it and you are using v0.9.1 of Delta.Engine.dll finding out why auto-updating is not working in your project is much harder, maybe you can send me your project or a simple test project to help me reproduce this issue.

I will try to create a project in v0.9.0 and test switching to v0.9.1 and see if auto-updating still works.

Edited by user Sunday, November 20, 2011 3:03:09 PM(UTC)  | Reason: Not specified

Offline vickfl  
#7 Posted : Sunday, November 20, 2011 3:37:27 PM(UTC)
vickfl

Joined: 10/7/2011(UTC)
Posts: 26
Location: L&#252;beck, SH, Germany

Thanks: 4 times
Was thanked: 2 time(s) in 2 post(s)
It is definitly no old DLL in my path as I deleted the whole bin-folder before upgrading. I also removed all References and added them again. I just tried it again, still no luck. Resizing the window also does not change a thing, it just scales with the wrong draw positions :-(

BUT, i think I figured something out:

If you start a new SimpleGame and run it, everything is just fine. Now put all the stuff into a new Screen, the game should look like this:
Code:

/// <summary>
    /// Game class, which is the entry point for this game. Manages all the game
    /// logic and displays everything. More complex games do this differently.
    /// </summary>
    class Game : DynamicModule
    {

        #region Constructor
        /// <summary>
        /// Constructor, do additional initialization code here if needed.
        /// </summary>
        public Game()
            : base("Simple Game", typeof(Application))
        {
            new GScreen().Open();
        }
        #endregion

        #region Run
        /// <summary>
        /// Run game loop, called every frame to do all game logic updating.
        /// Note: put your game logic here, it will be executed each frame.
        /// There is no difference between update code and render code as all
        /// rendering will happen optimized at the end of the frame anyway!
        /// </summary>
        public override void Run()
        {
        }
        #endregion
    }

    class GScreen : Screen
    {
        #region Constants
        /// <summary>
        /// Update the trail 60 times per second.
        /// </summary>
        private const int NumberOfUpdatesPerSecond = 60;
        /// <summary>
        /// Keep the trail for 2 seconds.
        /// </summary>
        private const int TrailLengthInSeconds = 2;
        /// <summary>
        /// Interpolate the trail to make it look more smooth than the input
        /// allowes (which might jump great distances).
        /// </summary>
        private const int NumberOfInterpolations = 3;
        #endregion

        #region Variables
        /// <summary>
        /// Just load the DeltaEngine image or if that is not available the
        /// DeltaEngineLogo image, which is always available.
        /// </summary>
        private readonly Material2DColored gameObject =
            new Material2DColored("DeltaEngineLogo");
        /// <summary>
        /// Welcome text, which can be changed once a UIClick happened.
        /// </summary>
        private string welcomeText =
            "Press Space, GamePad, Click or Touch to see the hidden message";
        /// <summary>
        /// Start drawing in the middle, but allow moving around with cursors or
        /// any input device returning position change (mouse, touch, gamepad).
        /// </summary>
        private Point drawLocation = Point.Half;

        /// <summary>
        /// Last positions for the trail that is slowly fading out.
        /// </summary>
        readonly List<Point> lastPositions = new List<Point>();
        /// <summary>
        /// Last times (in milliseconds) for the trail to reconstruct the size
        /// and rotation values.
        /// </summary>
        readonly List<long> lastTimeMs = new List<long>();
        /// <summary>
        /// Last colors for the trail to make everything a bit more colorful.
        /// </summary>
        readonly List<Color> lastColors = new List<Color>();
        /// <summary>
        /// Current color used for drawing the trail.
        /// </summary>
        private Color currentColor = Color.Random;
        /// <summary>
        /// Next color we are fading to for the trail.
        /// </summary>
        private Color nextColor = Color.Random;
        #endregion

        public GScreen() :base("Test")
        {
            // Note: Normally in a game you would define those commands via the
            // InputSettings.xml in the ContentManager, don't use the commands here!
            Input.Commands[Command.UIClick].Add(delegate
            {
                Application.BackgroundColor = Color.DarkBlue;
                welcomeText = "You made it! Yay. Now write some game code :)";
            });
            CommandDelegate moveDrawLocation = delegate(CommandTrigger command)
            {
                //Log.Info("Position=" + command.Position + ", from " + command.Button);
                drawLocation = command.Position;//.Movement / 10.0f;
            };
            Input.Commands[Command.CameraRotateLeft].Add(moveDrawLocation);
            Input.Commands[Command.CameraRotateRight].Add(moveDrawLocation);
            Input.Commands[Command.CameraRotateUp].Add(moveDrawLocation);
            Input.Commands[Command.CameraRotateDown].Add(moveDrawLocation);
            Input.Commands[Command.QuitTest].Add(delegate
            {
                Application.Quit();
            });
        }

        protected override void  Draw()
        {
 	        base.Draw();
            
            // Show FPS
            Font.Default.DrawTopLeft("FPS: " + Time.Fps);

            // Draw the trail and then the current object
            for (int num = 0; num < lastPositions.Count; num++)
            {
                DrawGameObject(lastPositions[num], lastTimeMs[num], lastColors[num],
                    num / (float)lastPositions.Count);
            }
            DrawGameObject(drawLocation, Time.Milliseconds, Color.White, 1.0f);

            // Change color every second
            if (Time.EverySecond)
            {
                currentColor = nextColor;
                nextColor = Color.Random;
            }

            // Remember position for the trail 30 times per second.
            if (Time.CheckEvery(1.0f / NumberOfUpdatesPerSecond))
            {
                while (lastPositions.Count >
                    NumberOfUpdatesPerSecond * TrailLengthInSeconds)
                {
                    lastPositions.RemoveAt(0);
                    lastTimeMs.RemoveAt(0);
                    lastColors.RemoveAt(0);
                }
                float colorPerecentage = (Time.Milliseconds % 1000) / 1000.0f;
                Color newColor = Color.Lerp(currentColor, nextColor,
                    colorPerecentage);
                // Add few interpolated entries between this one and the last, this
                // will make the output look much more smooth :)
                if (lastPositions.Count >= NumberOfInterpolations)
                {
                    // This way the output looks more smooth :)
                    Point p1 = drawLocation;
                    Point p2 = lastPositions[
                        lastPositions.Count - NumberOfInterpolations];
                    long t1 = Time.Milliseconds;
                    long t2 = lastTimeMs[
                        lastTimeMs.Count - NumberOfInterpolations];
                    for (int num = 1; num < NumberOfInterpolations; num++)
                    {
                        float interpolation = num / (float)NumberOfInterpolations;
                        lastPositions.Add(Point.Lerp(p1, p2, interpolation));
                        lastTimeMs.Add(MathHelper.Lerp(t1, t2, interpolation));
                        lastColors.Add(newColor);
                    }
                }
                lastPositions.Add(drawLocation);
                lastTimeMs.Add(Time.Milliseconds);
                lastColors.Add(newColor);
            }

            // And a simple text message
            Font.Default.DrawCentered(welcomeText, new Point(0.5f,
                ScreenSpace.DrawArea.Bottom - Font.Default.LineHeight / 2));
        }
        

        #region DrawGameObject
        /// <summary>
        /// Draw game object, also used for the trail.
        /// </summary>
        /// <param name="position">Current position</param>
        /// <param name="milliseconds">Time for this object or trail</param>
        /// <param name="color">Color for the trail</param>
        /// <param name="alpha">Alpha for drawing</param>
        private void DrawGameObject(Point position, long milliseconds, Color color,
            float alpha)
        {
            gameObject.BlendColor = new Color(color, alpha);
            gameObject.Draw(Rectangle.FromCenter(position, gameObject.Size + 0.5f *
                gameObject.Size * MathHelper.Sin(milliseconds / 20.0f)),
                milliseconds / 10.0f);
        }
        #endregion
    }


Compare the draw position of the logo to the one from the "clean" game! Surprise! Look at your pointer! ThumpUp
Offline Benjamin  
#8 Posted : Sunday, November 20, 2011 4:15:01 PM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Interesting, will try it out ...
Offline Benjamin  
#9 Posted : Monday, November 21, 2011 1:40:31 AM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Finally found the issue. An optimization that works great when the first rendering that happens uses a custom 2d render matrix (like fonts, scenes, custom geomerty, etc.), but if the first render geometry is a material.Draw, the InternalViewProjection2D matrix is not updated (because the optimization thinks it is still set from the initialization or last frame).

Now finally fixed BigGrin

Maybe we should also put up a scenes tutorial after we are done with some refactoring for scenes, which is planed for v0.9.2. ThumpUp
thanks 1 user thanked Benjamin for this useful post.
vickfl on 11/21/2011(UTC)
Offline CARUFO  
#10 Posted : Monday, November 21, 2011 1:39:12 PM(UTC)
CARUFO

Joined: 8/21/2011(UTC)
Posts: 37

Was thanked: 1 time(s) in 1 post(s)
Thanks, it works in 0.9.1.1.
Offline mc-kay  
#11 Posted : Tuesday, November 22, 2011 9:37:19 PM(UTC)
mc-kay

Medals: Admin

Joined: 8/24/2011(UTC)
Posts: 138
Location: Hannover

Thanks: 1 times
Was thanked: 12 time(s) in 7 post(s)
Have the same error here with the latest version (0.9.1.1).
Doing this:
Code:
Material2DColored background = new Material2DColored(Color.Brown);
background.Draw(Rectangle.One);


Result in this exception:

Edited by user Tuesday, November 22, 2011 9:43:26 PM(UTC)  | Reason: Not specified

Offline Benjamin  
#12 Posted : Tuesday, November 22, 2011 10:07:35 PM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Thanks for the bug report. The first thing I noticed is that your warning stack trace is messed up with german and english mixed up.

Why the material seems to be messed up makes no sense for me, I could not reproduce it, but I will try with v0.9.1.1. You could check if your background Material instance has everything setup correctly in the debugger locals watch window (especially the cachedLayer and drawMode). Maybe those are null for some reason.
Offline mc-kay  
#13 Posted : Tuesday, November 22, 2011 11:26:57 PM(UTC)
mc-kay

Medals: Admin

Joined: 8/24/2011(UTC)
Posts: 138
Location: Hannover

Thanks: 1 times
Was thanked: 12 time(s) in 7 post(s)
The only think I noticed yet is that "background.Name" is null, and when doing this:
Code:
Material2DColored background = new Material2DColored(string.Empty, Color.Brown);
background.Draw(Rectangle.One);

Everything works fine (of course he is drawing the default textured shader too with a brown overlay.)
So maybe the problem is that the "Name" property is null?!

However I'm not able to step into the "cachedLayer.Add" method in Material2DColored.Draw.
I looked a bit around but I can't finde the source code for this part ("Go to definition" brings me to the "Delta.Rendering.dll" assembly's metadata).

Edited by user Tuesday, November 22, 2011 11:30:20 PM(UTC)  | Reason: Not specified

Offline Benjamin  
#14 Posted : Tuesday, November 22, 2011 11:58:24 PM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Yes, the RenderLayer.Add is currently part of Delta.Rendering.dll, which is not very final yet, so we kept don't make it public yet.

It must have something to do with the new refactorings for v0.9.1.1 and probably it is something with Name = null, which we overlooked. Thanks for the hint, will be fixed asap ^^
Offline Benjamin  
#15 Posted : Thursday, November 24, 2011 3:29:37 AM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
All fixed now, it was not the name after all, it was the fact that there was no diffuseMap set in the material with just a color (Using string.Empty creates an empty fallback image).

Also improved the stack trace to merge english and german lines.
Rss Feed  Atom Feed
Users browsing this topic
OceanSpiders 2.0
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2023, Yet Another Forum.NET
This page was generated in 0.170 seconds.