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 > Transparency and libnds?

#131086 - sourcerer - Sun Jun 10, 2007 11:25 pm

Hi,
I am trying to do something oh so simple, get a texture to be transparent (not alpha, but pixels with color 0 being rendered transparent).
I thought it would be as easy as adding in a GL_TEXTURE_COLOR0_TRANSPARENT in the glTexImage2D but it doesn't seem to do what I thought it would. (Tried it in NEHE sample 08, even threw a bunch of zeroes in the texture to make sure it was color0).

Is there anything else I should set as polyflag? Tried DECAL but I think that didn't do what I wanted either (though I tried so many permutations and got no luck :o\ )

Any hint would be greatly appreciated.

Kaj

#131119 - sourcerer - Mon Jun 11, 2007 10:09 am

...does anyone have an example using libnds that draws a textured quad with pixels in color 0 showing the polygon (or whatever, as long as it's no black bachground for obvious reasons) behind it?

I'd be very grateful.

Kaj

#131124 - Dark Knight ez - Mon Jun 11, 2007 10:43 am

Say you've got this right now:
Code:
glTexImage2D(0, 0, GL_RGB256, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, (u8*)buffer);

You'll need to change it into this:
Code:
glTexImage2D(0, 0, GL_RGB256, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD | (1 << 29), (u8*)buffer);

_________________
AmplituDS website

#131125 - sourcerer - Mon Jun 11, 2007 10:52 am

Thx, that's what I thought would do the trick, but GL_TEXTURE_COLOR0_TRANSPARENT equals 1<<29 and it didn't do what I thought so I wonder if I need to set a polygon attribute as well? Unless I did something stupid elsewhere as well, I've been known to do that occasionally.

Kaj

#131127 - Dark Knight ez - Mon Jun 11, 2007 11:08 am

I think it is required to load in the palette seperately with gluTexLoadPal and then set it when required with the glColorTable call.
Check for 3D examples which use those commands and then make your own project use them.
_________________
AmplituDS website

#131129 - sourcerer - Mon Jun 11, 2007 11:22 am

Thanks, will have a look at those :o)