Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprites not rendering with rebuilt effects #3750

Closed
emarcotte opened this issue Apr 22, 2015 · 13 comments · Fixed by #3785
Closed

Sprites not rendering with rebuilt effects #3750

emarcotte opened this issue Apr 22, 2015 · 13 comments · Fixed by #3785

Comments

@emarcotte
Copy link
Contributor

Hi,

After a long while not pulling any changes from github, I just updated my linux system with the latest of the develop branch. After doing so, none of my sprites render at all in a simple 2d game.

Doing a bisect from v3.3 to the latest seems to indicate that commit c089aa8
from #3706 is the first one where they all disappeared.

A simple game class that reproduces the issue is as follows... requires a texture2d named texture/player...

using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;

namespace DeathDeathEvolution {
    public class DDE : Game {
        GraphicsDeviceManager graphics;
        Texture2D image;
        SpriteBatch spriteBatch;

        public DDE() {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void LoadContent() {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            image = Content.Load<Texture2D>("texture/player");
        }

        protected override void Update(GameTime gameTime) {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape)) {
                Exit();
                return;
            }
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime) {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            base.Draw(gameTime);

            spriteBatch.Begin(
                sortMode: SpriteSortMode.BackToFront,
                samplerState: SamplerState.PointClamp,
                blendState: BlendState.AlphaBlend
            );

            spriteBatch.Draw(
                image,
                new Vector2(100, 100),
                null,
                null,
                null,
                0,
                null,
                Color.White,
                SpriteEffects.None,
                1
            );
            spriteBatch.End();
        }
    }
}

When running this game I don't get any (abnormal) output, just the previously reported linux warnings from opentk which are on another issue:

X Error of failed request:  BadCursor (invalid Cursor parameter)
  Major opcode of failed request:  95 (X_FreeCursor)
  Resource id in failed request:  0x2e00005
  Serial number of failed request:  226
  Current serial number in output stream:  228
AL lib: (EE) alc_cleanup: 1 device not closed

I'm not sure what other information is relevant here. Let me know what else I can provide.

@emarcotte
Copy link
Contributor Author

Quick note: The depth on the draw call seems to be important and relevant to the change. Setting the depth to 0 the sprites show up, setting to 1 they do not. I do not have a proper XNA capable system to compare behavior.

@tomspilman
Copy link
Member

@tgjones - Ideas?

@tgjones
Copy link
Contributor

tgjones commented Apr 23, 2015

@emarcotte Can you try finding out the maximum layerDepth you can use before the sprites disappear? 0.999? 0.5? Knowing that would help track the cause down.

@emarcotte
Copy link
Contributor Author

@tgjones 0 seems to be the max and -1.0 seems to be the min, or at least within a .0000001ish

@tgjones
Copy link
Contributor

tgjones commented Apr 29, 2015

Thanks @emarcotte.

@tomspilman This seems like something that should be fixed before v3.4 is released, but I haven't had time to look at it yet. I see you're getting ready to release v3.4, so I'll look at it asap, but if someone else beats me to it, even better...

@tomspilman
Copy link
Member

This seems like something that should be fixed before v3.4 is released

Unless it can be fixed in the next hour or two... 3.4 is being released with this bug in it.

@tomspilman
Copy link
Member

@tgjones - Should i wait? I have some time, but not alot.

@tgjones
Copy link
Contributor

tgjones commented Apr 29, 2015

I'm having a look at it right now, I'll keep you posted.

@tomspilman
Copy link
Member

Got it.

@tgjones
Copy link
Contributor

tgjones commented Apr 29, 2015

I've added a failing test, that demonstrates exactly the behaviour that @emarcotte described:
b5fda34

The test is based on XNA behaviour, and passes for WindowsDX, but fails for WindowsGL. I'll have a look at why, now...

@tomspilman
Copy link
Member

Fantastic!

@tgjones
Copy link
Contributor

tgjones commented Apr 29, 2015

And I've got a fix... checking in now. This actually fixes the Draw_with_SpriteSortMode tests as well, which were all previously broken for OpenGL.

@tgjones
Copy link
Contributor

tgjones commented Apr 29, 2015

PR created...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants