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 > 3D rendering on top of 2D backgrounds

#98330 - Lick - Mon Aug 14, 2006 6:49 pm

Hey guys,

I'm trying to draw 3D objects (actually, they're textured quads) on top of the 2D drawn backgrounds and unsurprisingly, it does not work.

Code:
        powerON(POWER_ALL);

       videoSetMode(
            MODE_5_3D |
            DISPLAY_BG0_ACTIVE |
            DISPLAY_BG1_ACTIVE |
            DISPLAY_SPR_ACTIVE |
            DISPLAY_SPR_1D |
            DISPLAY_SPR_1D_BMP);

       videoSetModeSub(MODE_0_2D
            | DISPLAY_BG0_ACTIVE | DISPLAY_BG1_ACTIVE);

        vramSetMainBanks(VRAM_A_MAIN_BG, VRAM_B_MAIN_BG,
            VRAM_C_SUB_BG, VRAM_D_TEXTURE);
        vramSetBankF(VRAM_F_MAIN_SPRITE);


I have set BG0's (3D) priority to 0 and BG1's (2D) priority to 1 (tested 2, 3 also). However it seems like the 3D rendering is working correctly, but it overrides my 2D memory, as I get garbage image data but my map data still creates the 'shapes' of my tiled background.
So It's probably something with the VRAM, but what..

Has anyone successfully done this yet, by the way?
_________________
http://licklick.wordpress.com

#98331 - MaHe - Mon Aug 14, 2006 7:07 pm

It's definitely possible (Submarine Tech Demo, New Super Mario Bros), however, I can't seem to work it out either ...
_________________
[ Crimson and Black Nintendo DS Lite | CycloDS Evolution | EZ-Flash 3-in-1 | 1 GB Transcend microSD ]

#98336 - Lick - Mon Aug 14, 2006 7:16 pm

Would involving the screen capturer make it slower or is that the correct way of doing it? I've no idea.
_________________
http://licklick.wordpress.com

#98342 - omaremad - Mon Aug 14, 2006 8:09 pm

i have done it in my waves demo, its pretty easy make sure the clear depth for 3d is black and use this code

Code:

BG2_CR = BG_BMP16_256x256 | BLEND_ALPHA | BG_PRIORITY(0)|BG_WRAP_ON;
   BG0_CR =BG_PRIORITY(3)|BLEND_ALPHA;
   SUB_BG2_CR = BG_BMP16_256x256|BLEND_NONE;

   BLEND_CR = (2<<6) | BLEND_DST_BG2 | BLEND_SRC_BG0;
   BLEND_AB = 15 | (15<<8);