开发者

XNA Content.Load() Memory Usage

In XNA, when calling Content.Load() to load in a resource, if you load the same resource into multiple objects (i.e. the texture for a projectile of which there can be many) are y开发者_运维知识库ou getting a copy for each object, or is the system just internally referencing the same memory for each one?

I was realizing that having a separate Texture2D object in each item may be a memory issue down the line.


The ContentManager will cache the object and return the reference to that object when you try to load it again.


Yes modifying the texture data will change all textures that reference that data.

If you need multiple ones then duplicate the original file and load different versions.


You would need to make a new Texture2D object and simply copy the changed data into the new texture with the SetData method:
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.texture2d.setdata.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜