#40313 - Locke - Sun Apr 17, 2005 12:31 pm
Hi, I started messing up whith my DS and ndslib yesterday, and I have some begginer questions...
I can't figure out the texture format nds uses, so I checked the textured cube example and tried to replace the texture.bin included with my own texture.bin (raw, same size and 16 bit). Didn't work, I only get a black and grey model.
I beleive that the problem is the raw format I'm using. Is there any tool to convert a 24bit bmp to the appropiate raw format?
Why DS can't handle v16 math? I was trying to calculate some normal tables at loading time...
#40316 - FeaRog - Sun Apr 17, 2005 2:28 pm
The textures are in the following format:
But because of the endian-ness it'll look like this in memory:
Code: |
Byte n Byte n+1
GGGRRRRR ABBBBBGG |
#40319 - ector - Sun Apr 17, 2005 2:36 pm
Yeah but that will happen automatically if you write 16-bit values straigt to a file since PC is little-endian too.
And remember to put a 1 in the A bit.
#40325 - tepples - Sun Apr 17, 2005 4:14 pm
ector wrote: |
Yeah but that will happen automatically if you write 16-bit values straigt to a file since PC is little-endian too. |
The Mac is not little-endian. If you plan to release your tools as free software or if you envision porting your tools to another platform, please make them handle data byte-by-byte rather than using chance coincidences to serialize data.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#40328 - FeaRog - Sun Apr 17, 2005 4:32 pm
What he said ;)
#40358 - Locke - Sun Apr 17, 2005 11:18 pm
Ok, I think I got it (although sometimes I get a blue-like texture...).
Another question: texture coordinates range from 0 to (TEX_WIDTH - 1) and 0 to (TEX_HEIGHT - 1), do they? Im getting weird texture mapping and I can't figure out the reason...
[Images not permitted - Click here to view it]
#40388 - Locke - Mon Apr 18, 2005 9:54 am
I finally made it. Now we have... YET ANOTHER MD2 VIEWER!! >_<
I don't feel like releasing at the moment, as it is not a very interesting piece of code. It was just a little practicing for me.
Thanks for the help. ;)
http://www.filespace.org.nyud.net:8090/Locke/ogre_ds2.jpg
#41628 - Locke - Sat Apr 30, 2005 1:43 pm
Another question about textures. I want to use 2 at a time on the screen. One for the model and one for the bg.
I initialize my textures as follows:
Code: |
int textures[2];
vramSetBankA(VRAM_A_TEXTURE);
glGenTextures(2, &textures[0]);
glBindTexture(0, textures[0]);
glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, 0, (u8*)model_tex);
glBindTexture(0, textures[1]);
glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_64, TEXTURE_SIZE_64, 0, 0, (u8*)bg_tex); |
And with this lines inside my main loop:
Code: |
glBindTexture(0, textures[0]);
DrawModel();
glBindTexture(0, textures[1]);
DrawBg(); |
The textures[0] thing works fine, but second one looks like the first with messed sizes. Am I doing something wrong or is it just an emu/lib issue? I don't undestand very well how texture memory works, but I think that my code is correct...
Thanks
#41634 - bluescrn - Sat Apr 30, 2005 3:48 pm
Have you tried it on hardware?
I've got 2 textures (a 64x64 and a 128x128) working together on hardware, but it doesn't work in iDeaS. (iDeaS also seems to ignore texture alpha, as I found out when my polygons all disappeared on hardware...)
Another texture-related question, does the DS support U/V wrapping, and if so, does anyone know how to enable it?
#41642 - mike260 - Sat Apr 30, 2005 6:16 pm
bluescrn wrote: |
Another texture-related question, does the DS support U/V wrapping, and if so, does anyone know how to enable it? |
When you load a texture, you can specify GL_TEXTURE_REPEAT_[S|T] to enable wrapping, otherwise I think you get clamping. The hardware also appears to support mirroring via GL_TEXTURE_FLIP_[S|T].
#41697 - rize - Sun May 01, 2005 8:17 am
ector wrote: |
And remember to put a 1 in the A bit. |
Why? I was under the impression that a is for alpha and that generally you would want your alpha bits set to 0 unless you need alpha.
However, I mostly just made that up based on limited prior knowledge of the 8 alpha bits in 32 bit color (which I assumed were set to 0000 0000 for an opaque texture).
#41705 - ector - Sun May 01, 2005 11:11 am
With 8-bit alpha, 0 = completely transparent (nothing is drawn), not opaque.
Same thing usually with 1-bit alpha