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 > alpha opengl

#166096 - hacker013 - Mon Jan 26, 2009 5:47 pm

hey everybody,

has someone some code so i can set the alpha with opengl because functions like glColor4d are not yet included.

gr,

hacker013
_________________
Website / Blog

Let the nds be with you.

#166097 - Izhido - Mon Jan 26, 2009 6:09 pm

It's my sad duty to report that, unfortunately, it's highly unlikely that we'll see functions as glColor4d() ever on libnds.

You see, the DS hardware is not quite OpenGL compliant. There are some things missing (as well as some things you wouldn't even dream that could appear on OpenGL :D ). In one of the missing things, you can specify alpha for a FULL quad / triangle, instead of per vertex.

You can specify an alpha for the next polygons being drawn, by writing to bits 16-20 of GFX_POLY_FORMAT. Not sure if there's a glPolyFmt() option for that.

Hope that helps.

- Izhido

#166098 - elhobbs - Mon Jan 26, 2009 6:28 pm

alpha is per poly not per vertex
http://nocash.emubase.de/gbatek.htm#ds3dtextureblending
it can be set using glPolyFmt and POLY_ALPHA. Here is some code that I use. It is used to render the dual scrolling sky layer in cquake.
Code:


//set texture blending and draw lower layer
glPolyFmt(POLY_ALPHA(31) | POLY_CULL_FRONT | POLY_ID(1)|1<<13));
EmitSkyPolys (fa,pts);

//set to transparent and ztest equal for top layer
//bit 14 set depth test equal
//bit 11 enables depth writes for translucent polys
glPolyFmt(POLY_ALPHA(16)|POLY_CULL_FRONT|POLY_ID(4)|(1<<14)|(0<<11) | POLY_MODULATION);
EmitSkyPolys (fa,pts);

//set polyformat back to normal
glPolyFmt(POLY_ALPHA(31) | POLY_CULL_FRONT | POLY_ID(1) | (1<<13));


you may or may not want the depth test equal for your alpha polys - just turn off bit 14. if you do want depth test equal it will ony work with glFlush(0) - glFlush(2) causes depth test equal to produce odd artifacts.

#166099 - hacker013 - Mon Jan 26, 2009 7:16 pm

thx, if fixed it.
_________________
Website / Blog

Let the nds be with you.