Archived

This topic is now archived and is closed to further replies.

MAn these texture coords are driving me nuts!!!

This topic is 5753 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I can'';t figure out what teh problem is. In my 2d game, all sprites get loaded correctly, even if the sprite is say 640x480, my code will break it up into tiles and blit it properly. But, when I load an 8x8 bmp it wont work, it has very odd behavior. From what I can tell it loads the 8x8 graphic onto a 32x32 tile. Now, if it sets the tex coords to 0,0,.25,.25 it just draws a big grey BLOCK (This is a 8x8 image of a grey ball with transparency), it just draws an 8x8 one colored block. However, if i set my tex coords to 0,0,1.0,1.0 it draws it fine!!!?!?!?!? WHY??? The coordinates for drawing are 0,0,8,8, so those tex coords should draw a really small ball, but it draws it properly, but the 0,0,.25,.25 dont work at all??? How very very strange, its drivin me nuts! The code works wtih pretty much any other sized image, I guess except ones smaller than 32x32 (I''m guessing) any ideas? ByteMe95::~ByteMe95() My S(h)ite

Share this post


Link to post
Share on other sites
Thing is Byte, if I understand how the D3DX texture loading functions work then I''d expect your 8*8 bitmap to be stretched to cover the entire 32*32 texture block (it doesn''t put the 8*8 in one corner and put a black border around it or anything).

In which case your results make sense (0-0.25 is only one quarter of the texture, and I guess that block looks mostly black or something).

Share this post


Link to post
Share on other sites
Hmmmmm
can you be more specific as to WHEN the d3dx texture creation functions would stretch out the image?
I dont actually use the createfromfile function, I load the image onto a surface, then I break up the surface, creating textures as needed, and then copying a rect from the source image to the texture
so for the 8x8, i load the image to a surface, create a 32x32 texture then copyrect an 8x8 rect from the surface to the texture, so I dont think that is the reasoning

ByteMe95::~ByteMe95()
My S(h)ite

Share this post


Link to post
Share on other sites
hmm.. I assumed you were using the d3dx file to texture functions. I don''t know much about the surface from file functions.

It still sounds like your 8*8 is getting stretched but I couldn''t say why.

Share this post


Link to post
Share on other sites
quote:
Original post by ByteMe95
I can'';t figure out what teh problem is. In my 2d game, all sprites get loaded correctly, even if the sprite is say 640x480, my code will break it up into tiles and blit it properly.
But, when I load an 8x8 bmp it wont work, it has very odd behavior.
From what I can tell it loads the 8x8 graphic onto a 32x32 tile. Now, if it sets the tex coords to 0,0,.25,.25 it just draws a big grey BLOCK (This is a 8x8 image of a grey ball with transparency), it just draws an 8x8 one colored block.

However, if i set my tex coords to 0,0,1.0,1.0 it draws it fine!!!?!?!?!? WHY???
The coordinates for drawing are 0,0,8,8, so those tex coords should draw a really small ball, but it draws it properly, but the 0,0,.25,.25 dont work at all??? How very very strange, its drivin me nuts!

The code works wtih pretty much any other sized image, I guess except ones smaller than 32x32 (I''m guessing)
any ideas?

ByteMe95::~ByteMe95()
My S(h)ite


I can think of two possible explanations:

1) An 8x8 texture is smaller than what is supported by your card. Not all cards will support textures that small.

2) Direct3D''s texture coordinates are based off of a (0.0-1.0) scale. On an 8x8 texture, (0,0)-(0.25,0.25) would be equivalent to the 4 pixels in the upper-left corner (0,0)-(1,1).

RomSteady - Able to leap off tall buildings in a single bound

Share this post


Link to post
Share on other sites
Rom,
I''m not actually creating an 8x8 texture, I create a 32x32 texture and copy the 8x8 image to the upper left hand corner of the texture.
Then when I render, since the image only occupies an 8x8 portion of a 32x32 texture, the tex coords I WOULD THINK should be 0,0,.25,.25 so it just uses the 8x8 part of the texture and not the rest.
Again, it seems to work that way for everything else...

ByteMe95::~ByteMe95()
My S(h)ite

Share this post


Link to post
Share on other sites
but I think the quesiton byte is, does your card supoorte 8 by 8 surfaces? If it doesn''t support anything smaller than a 32 by 32 surface...

Share this post


Link to post
Share on other sites
hmmmmm, good point well played, but why would there ever be a limit on surface sizes minimum size?? Surface are arbitrary sizes of video memory, textures have stricter requirements because they increase 3d rendering speed.

I know using dx5 in my last big project I had many sprites less than 32x32, even smaller than 8x8.
I never heard of surface size restricitons (except for surface width, which doesnt pertain to this)

ByteMe95::~ByteMe95()
My S(h)ite

Share this post


Link to post
Share on other sites