Texture coordinates don't have to be 1,2,3..100 they can be any floating point value, 0.0025 is a valid texture coordinate. The GPU takes care of transforming your texture coordinate into the correct pixels in the actual texture image. The normal range is 0...1 if you want to show the whole texture, but if you go over one it will repeat on itself if the wrap state is setup that way.
When using atlas textures the texture coordinates of your objects need to be scaled to the range the texture takes in the atlas texture, and you don't store this as pixels but as actual coordinates to make it easier on yourself during drawing.
Well,i got a good idea for two ways,finally idea:
When i make texture atlas put same theme's texture as much as possible together,just don't call SetTexture() as much as possible.But if really need other theme's texture,make a texture atlas before drawing,i think it will be very quick and i only need to call SetTexture() for twice.
yes,i know that, i know we usually use from 0 to 1,i mean..well,for a example
i have a texture ,size is 369x153,i called it A.
i have another texture ,size is 694x237,i called it B.
Well,if i make a texture atlas,size is 1024x1024 and i want to put these two texture like that:
(0,1024),(0,0)┏━━┓(1024,1024),(1,0)
┃A B ┃
┃┃
(0,0),(0,1)┗━━┛(1024,0),(1,1)
first coordinate is pixel coordinate,second is texture coordinate
well,that is the layout,but what is the texture coordinate for A?
should it like that?
left-top:(0,0)
right-top:(369/1024,0) //369 divide by 1024,because the width of A is 369,and the width of texture atlas is 1024
left-bottom:(0,153/1024) //153 divide by 1024,because the height of A is 153,and the height of texture atlas is 1024
right-bottom:(369/1024,153/1024) //same
i think it may be like that,but it has a problem,369 divide by 1024 is a recurring decimal ,so i think the GPU can't get a right pixel value for the width of A,and other is same.
So,should i change the size of texture atlas to 1000,then is won't be a recurring decimal 0.369(369/1000),should i do that?Please tell me.
And i have another question,how many decimal places could pass to GPU,if i pass 0.0025 to GPU,will it make it to 2 decimal places?Does it decide by float?
Thank you very much!
Edited by AlanWu, 10 December 2012 - 04:10 PM.