Jump to content

  • Log In with Google      Sign In   
  • Create Account


XNA - Texture2D won't get rendered after ~10 frames.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 FelixK15   Members   -  Reputation: 236

Like
0Likes
Like

Posted 11 March 2013 - 02:18 AM

Hi guys,

 

I'm facing a very strange error with an XNA project of mine.

 

I rewrote some things during the weekend on my laptop (I was on vacation).

After I checked that everything went smoothly, I pushed it to my git repository.

 

When I cam home yesterday I pulled everything from the repository to my pc at home.

 

I just wanted to continue to work on the project when I realized that - on my pc - all

Texture2D (e.g. all my sprites) are getting rendered for ~10 frames. After that the sprites

just disappear and I'm left with a violet screen.

 

However, when I start the project on my laptop everything works fine.

 

My suggestion was that I dispose something where I shouldn't, so I commented every Dispose() that was called out.

Sadly, that didn't change anything.

 

Do any of you guys have any suggestion what I can do, to corner that issue?


Visit my blog or follow me on twitter.

Sponsor:

#2 Andy474   Members   -  Reputation: 675

Like
0Likes
Like

Posted 11 March 2013 - 05:11 AM

IS the violet screen your background color? so what you set with GraphicsDevice.Clear(): ?

 

- Is the draw call defiantly still being called?

- Do the images have any transparency maps? E.g. Magenta gets cancelled

 

- Check where you are loading the Texture, I recall having a problem on a project a long time ago where I loaded a Sprite each time the user hit the Space bar, and that changed the Original Image (it was a randomly colored shape) (try making sure each sprite Loads in a new Instance of the texture)

 

- Are you using RenderTargets? If so, are you defiantly doing GraphicsDevice.SetRenderTarget(null); After?

When you draw, are you defiantly Drawing with Sprite batch.Draw(Texture, Position ..., Color.WHITE); <-- and not like a null colour, or Color.Transparent.

 

- Are you using REACH on your laptop, and Hi-def on your PC? or (V sa V).

 

These are the only things that come to mind atm.



#3 adt7   Members   -  Reputation: 425

Like
1Likes
Like

Posted 11 March 2013 - 08:32 AM

I noticed you mentioned you removed some Dispose() calls. I can't think of any regular situation where you'd need to call Dispose on a Texture in XNA, so this rings alarms bells for me.

 

Could you post up some code or link to your repository? It might offer some clues to what's going on.



#4 FelixK15   Members   -  Reputation: 236

Like
0Likes
Like

Posted 11 March 2013 - 09:14 AM

@Andy474

I checked everything you said, but it seemed ok.

What do you mean with 

Are you using REACH on your laptop, and Hi-def on your PC? or (V sa V).

 

@adt7

I read once that you should Dispose() all XNA resources that have not being loaded by the ContentManager.

 

The code would be too long to post it here, so here's the link to my repository:

https://FelixK15@bitbucket.org/FelixK15/rpg-xna-project.git

 

Thanks for looking through my code. I hardly suspect the GameWorldLoader class to be the source of the problem.

If anything is unclear or you got questions, either send me a PM or

add me on Skype (you can find my username in my profile)

 

---

 

I also recorded the behavior because it is pretty complicated to describe it.

(The video is a bit messed up at the beginning, but it gets better after a few seconds)

 

During recording I also realized that some of the tiles are not getting rendered (the violet squares),

however after I restart the program during the stream some of the previously not rendered tiles are

getting rendered and others are not. You can see the behavior in the video as I restarted the program 3 times in the video.


Visit my blog or follow me on twitter.

#5 FelixK15   Members   -  Reputation: 236

Like
0Likes
Like

Posted 11 March 2013 - 10:13 AM

It seems to be a problem with the driver from my ATI graphicscard. A friend of mine has the same card, but had old drivers. The game worked fine on his machine using the old drivers. However, as soon as he updated his driver so that our driver versions match, he had the exact same error as I.


Visit my blog or follow me on twitter.

#6 phil_t   Crossbones+   -  Reputation: 3254

Like
0Likes
Like

Posted 11 March 2013 - 11:20 AM

The link to your repository is broken.

#7 FelixK15   Members   -  Reputation: 236

Like
0Likes
Like

Posted 11 March 2013 - 11:23 AM

$git clone https://FelixK15@bitbucket.org/FelixK15/rpg-xna-project.git 
 

 

works perfectly for me


Visit my blog or follow me on twitter.

#8 phil_t   Crossbones+   -  Reputation: 3254

Like
0Likes
Like

Posted 11 March 2013 - 12:26 PM

Ah ok, I don't have any kind of git client installed on my machine.

I found a link that lets me browse the source on the web:
https://bitbucket.org/FelixK15/rpg-xna-project/src/f7432d3121e6?at=master
But is there any way to download it as a zip file or something?

#9 FelixK15   Members   -  Reputation: 236

Like
0Likes
Like

Posted 11 March 2013 - 12:47 PM

Here you go 

https://bitbucket.org/FelixK15/rpg-xna-project/get/f7432d3121e6.zip


Visit my blog or follow me on twitter.

#10 phil_t   Crossbones+   -  Reputation: 3254

Like
0Likes
Like

Posted 11 March 2013 - 01:30 PM

Got it, thanks. It's pretty easy to repro, just minimize your game window and then restore it. This causes the graphics device to be lost.

(For some reason your graphics drivers are causing it to be lost more frequently or something. At any rate, this is something you need to handle).

When the device is reset, the contents of any RenderTarget2D will be lost (also true for DynamicVertexBuffer). You'll need to regenerate the data in response to the RenderTArget2D.ContentLost event.

#11 FelixK15   Members   -  Reputation: 236

Like
0Likes
Like

Posted 11 March 2013 - 01:39 PM

Actually that is not *quite* the same problem as I'm having.

 

If I minimize the game I can still see my player sprite and some of the other dynamic objects.

However my problem is that nothing gets drawn after a specific amount of frames (like in the video I posted).

 

The RenderTarget2D.ContentLost is also not getting called when my sprites stop getting drawn, however if I minimize/restore the window AFTER

the sprites disappear the sprites of the player and dynamic objects are getting drawn again.


Visit my blog or follow me on twitter.

#12 phil_t   Crossbones+   -  Reputation: 3254

Like
0Likes
Like

Posted 11 March 2013 - 02:10 PM

Hmm, you may be right, it might be something different.

I actually had it do some weird stuff while I was switching windows on the desktop (I know some stuff turned purple), and then I tried running it again and testing for the device lost which I described above. So it's possible that it did repro on my machine once, but I can't seem to repro it again. I can only get things to disappear if I force a device reset.

So I'm not sure what else to suggest at this point.

I looked at your code a bit. You're creating 496 render targets at startup. I know you Dispose them right away, but maybe it's somehow messing with your graphics card. I'm pretty sure there has to be an alternative way to do what you're doing.
Does it repro if you remove that code?

#13 FelixK15   Members   -  Reputation: 236

Like
0Likes
Like

Posted 11 March 2013 - 02:34 PM

Thanks for your hint!

 

The problem are in fact the RenderTargets.

 

I removed all RenderTargets from the GameWorldLoader and voila...it works.

 

Now I gotta find a workaround for that...gheez


Edited by FelixK15, 11 March 2013 - 02:34 PM.

Visit my blog or follow me on twitter.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS