gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > textured quad example doesn't work

#46249 - delfare - Wed Jun 22, 2005 8:05 am

I wonder why the textured quad example doesn't work anymore when it's compiled with next ndslib. Can anyone tell me?
_________________
If I speak badly, it's because I speak french and I am 15

PA 3d tutorial : http://delfare.pizz.biz

#46252 - Darkain - Wed Jun 22, 2005 9:39 am

this demo is slightly broken. ive mentioned it before, but not sure when someone with more 3d experience will get around to fixing it.

its a simple issue tho, something with the fact that they are relying on too many default values for lighting. this can be seen w/ my multi-nds loader, by loading a demo, returning to menu, and entering this demo. depending on the previous demos lighting, it will effect the lighting in this demo.
_________________
-=- Darkain Dragoon -=-
http://www.darkain.com
DarkStar for Nintendo DS

#46260 - Ethos - Wed Jun 22, 2005 1:12 pm

Material...has defaults of 0's....here are some real defaults

Code:
glMaterialf(GL_AMBIENT, BIT(15) | RGB15(19,19,19));
glMaterialf(GL_DIFFUSE, BIT(15) | RGB15(28,28,28));
glMaterialf(GL_SPECULAR, BIT(15) | RGB15(16,16,16));
glMaterialf(GL_EMISSION, BIT(15) | RGB15(16,16,16));

_________________
Ethos' Homepage (Demos/NDS 3D Tutorial)

#46267 - dovoto - Wed Jun 22, 2005 4:29 pm

Just checked out your site ethos...looks good. I was thinking of doing nehe stuff also...glad someone actualy took it up.
_________________
www.drunkencoders.com

#46272 - Ethos - Wed Jun 22, 2005 5:44 pm

lol, fix two things for me dovoto ;)

1) glBindTexture(0,0), should set GFX_TEX_FORMAT = 0, but right now it sets the texture to the first one loaded (textures[0]), easy fix would be to just start the texture loading at index 1 and a small if statement in the glBindTexture.
Code:
int glGenTextures(int n, int *names)
{
   static int name = 1;
...

Code:
void glBindTexture(int target, int name)
{
   if (name = 0)
      GFX_TEX_FORMAT = 0;
   else
      GFX_TEX_FORMAT = textures[name];
   
   activeTexture = name;
}


2)
Code:

#define f32tot16(n)             ((t16)(n >> 8))
void glTexCoord2f32(f32 u, f32 v) {
   int x=0,y=0;
   
   x = ((0x00700000) & textures[activeTexture]) >> 20;
   y = ((0x03800000) & textures[activeTexture]) >> 23;
      
   glTexCoord2t16(f32tot16 (mulf32(u,intof32(1<<(3+x)))), f32tot16 (mulf32(v,intof32(1<<(3+y)))));
}



Might be good to check if active texture is not 0 in functions :)
_________________
Ethos' Homepage (Demos/NDS 3D Tutorial)

#49167 - dovoto - Wed Jul 27, 2005 1:22 am

Done and commited to the CVS...a bit late i know but i am pretty lazy when it comes right down to it :)
_________________
www.drunkencoders.com