#152225 - ben0bi - Wed Mar 12, 2008 3:53 am
Hi,
I have some problems setting up the graphics properly:
i want to use 16bit direct draw.
Problems are the following:
- if i do NOT clear the Buffer, everything goes well. But the pixels are not deleted then...(moving stars demo)
- if i do clear the buffer, HALF of the screen will be blank.
- if i use doublebuffering, it WORKS - halfways.
(on the emulator everything is good, but on the real machine, the
half picture is darker than the other half.)
- if i set the doublebuffer memory into the main buffer memory, the darker screen will be drawn correct.
PLEASE help me, i really am frustrated, since 3 day i try to set up a SIMPLE background to draw to...(no framebuffer please..) - and how do i use one background over another, thats the next big question.
here is my source:
thanks in advance.
I have some problems setting up the graphics properly:
i want to use 16bit direct draw.
Problems are the following:
- if i do NOT clear the Buffer, everything goes well. But the pixels are not deleted then...(moving stars demo)
- if i do clear the buffer, HALF of the screen will be blank.
- if i use doublebuffering, it WORKS - halfways.
(on the emulator everything is good, but on the real machine, the
half picture is darker than the other half.)
- if i set the doublebuffer memory into the main buffer memory, the darker screen will be drawn correct.
PLEASE help me, i really am frustrated, since 3 day i try to set up a SIMPLE background to draw to...(no framebuffer please..) - and how do i use one background over another, thats the next big question.
here is my source:
Code: |
u16* g_pu16ActualDrawBuffer=NULL; bool actualBuffer=0; int main(void) { // irqs are nice irqInit(); irqSet(IRQ_VBLANK, 0); bool actualBuffer=0; videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE); vramSetBankA(VRAM_A_MAIN_BG_0x06000000); initConsole(); BG3_XDY = 0; BG3_XDX = 1 << 8; BG3_YDX = 0; BG3_YDY = 1 << 8; lcdMainOnBottom(); ... while(1) { if(actualBuffer) { actualBuffer=false; gfxSetDrawBuffer((u16*)BG_BMP_RAM(0)); BG3_CR = BG_BMP16_256x256 | BG_BMP_BASE(6); }else{ actualBuffer=true; gfxSetDrawBuffer((u16*)BG_BMP_RAM(6)); BG3_CR = BG_BMP16_256x256 | BG_BMP_BASE(0); } gfxClear(); swiWaitForVBlank(); ... gfxSetPixel(10,10,RGB15(31,0,0)) } } |
Code: |
void gfxClear(void) { for(int i=0;i<256*256;i++) g_pu16ActualDrawBuffer[i]=RGB15(0,0,0)|BIT(15); } void gfxSetDrawBuffer(u16* newBuffer) { g_pu16ActualDrawBuffer=newBuffer; } void gfxSetPixel(int pos,u16 color) { if(g_pu16ActualDrawBuffer!=NULL) { g_pu16ActualDrawBuffer[pos]=color|BIT(15); } } |
Code: |
void initConsole() { videoSetModeSub(MODE_2_2D | DISPLAY_BG0_ACTIVE); vramSetBankC(VRAM_C_SUB_BG); SUB_BG0_CR = BG_MAP_BASE(31); BG_PALETTE_SUB[255] = RGB15(31,31,31); consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); iprintf("\n\n\tBenoWorks Unlimited presents a DS game.\n"); } |
thanks in advance.