Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi there,

 

im using D3D sprites in my 2D game. Im storing textures in jpg and tga files, every time im creating a sprite with, say 150x150 tga texture file all seems to wrok fine, but my sprite's texture is being automatically resampled to fit 256x256. i have absolutely no idea why. any help would be greatly appreciated. ah yes, here is the code:

 

 

....

....

....

texture = TextureLoader.FromFile(device, @filename);

SurfaceDescription description = texture.GetLevelDescription(0);

textureSize = new Rectangle(0, 0, description.Width, description.Height);

....

....

 

Width and Height Fields semm to always be 256... :o

Posted
The Direct3D sprite class also has some wierd behavior, seen here http://www.gamedev.net/reference/articles/article1608.asp. It may or may not relate to your issue; however, I don't know alot about the sprite class in Direct3D. I know that ThePentiumGuy did a tutorial on Texturing a Quad, ie. making your own sprite class. I have had great success building of that base. I know it is not fun to rewrite working code, but I think you would find better luck with texturing your own quads, you have more control.

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

  • Leaders
Posted

I do believe that a texture must have dimensions that are powers of two, for example, 64,64, or 128,128, or 256,256. If you provide an image that is 150,150 it must be resampled in order to be compatible with graphics hardware.

 

I'm not positive that this can be done with a sprite, but it should be doable with a quad: Use a 256x256 texture on a 256x256 sprite/quad with a mask so that the area beyond 150,150 simply won't be visible. Of course, masks don't work so well with lossy image formats, so you would have to ditch the jpgs.

[sIGPIC]e[/sIGPIC]
Posted
Marble's right, only high-end video cards support non power of 2 sized textures. However, you can just pad your jpg's to 256x256 and pass a 150x150 rectangle to the sprite's Draw function.
"Who is John Galt?"
Posted

you must use

texture = TextureLoader.FromFile(device, @filename, 0, 0, 1, Usage.None, Format.Unknown, Pool.Managed, Filter.None, Filter.None, 0);

 

in place of

texture = TextureLoader.FromFile(device, @filename);

 

;)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...