Hello there. I'm new to Wii homebrew, but I have some familiarity with OpenGL.
I have a static 2D background that I'm drawing directly to the XFB. Now I want to draw 3D graphics on top of that background. I'm currently accomplishing this via the following:
// Draw 3D stuff, then...
GX_DrawDone();
GX_CopyDisp(xfb, GX_TRUE);
GX_DrawDone();
// Now I draw my background into the XFB, but I only overwrite pixels for which color == CLEAR_COLOR
Allow me to explain. Drawing 3D stuff draws to the EFB, and GX_DrawDone ensures the drawing has finished. GX_CopyDisp copies the EFB to the XFB, and GX_DrawDone ensures the copying has finished. At this point it is safe to directly modify the XFB. If an XFB pixel has color == CLEAR_COLOR, then no 3D stuff was drawn there, so I may safely copy my background color to that pixel. This method works fine, however, it's a bit clumsy.
The obvious alternative is to render my static 2D background into a texture, then write that texture to the EFB before drawing the 3D stuff. But this got me thinking. When a texture is drawn into the EFB, it's possible to do alpha and z comparison, which affects how that texture data is blended with the data already contained in the EFB. Wouldn't it be nice if we could apply a similar technique when the EFB is copied to the XFB? For example, only copy pixels from the EFB to the XFB if the z value is less than the clear value. I think this would be much more useful that just being able to specify a sub-region of the EFB to copy to the XFB. It would allow me to write my static 2D background to the XFB first, then copy (precisely) the 3D objects from the EFB to the XFB.
If anyone with an advanced understanding of GX wants to share any insight on this, it would be greatly appreciated.