At the end of the main loopWhen should you use gfxSwapBuffers() And gfxFlushBuffers() ?
Does it hangs at a certain point or it doesn't boot at all?Could someone give me an example of why/when homebrew doesn't boot 100% of the time.
Forgot to reuseAt the end of the main loop
main loop:
-Draw things
-Do things
-Flush and Swap
-Wait for vblank
It has been fixed, it didnt boot at allDoes it hangs at a certain point or it doesn't boot at all?
Oh yeah forgot itForgot to reuse
u8* gfxGetFramebuffer
--------------------- MERGED ---------------------------
It has been fixed, it didnt boot at all
you have to get framebuffer address every loop iteration?Oh yeah forgot it
Main loop:
-Get FB <---
-Draw things
-Do things
-Flush and Swap FB
-gspWaitForVBlank
Mmmm actually, I've never noticed this thing. You're true, this is weird. I've been using this list of operations to do in main loop since my first 3ds homebrew and I brought this error with me for almost 1 year.you have to get framebuffer address every loop iteration?
does it move around on your system? that's pretty weird.
IT doesn't matter if yo got a small app.Mmmm actually, I've never noticed this thing. You're true, this is weird. I've been using this list of operations to do in main loop since my first 3ds homebrew and I brought this error with me for almost 1 year.
The correct thing is:
-GetFB
MAIN LOOP:
-Draw things
-Do things
-Flush and Swap FB
-Wait for VBlank
?IT doesn't matter if yo got a small app.
But in the end it really flickers
Traditionally, you would wait for vblank before swapping buffers.?
Does your app flicker?
I do wait for a vblanc, and since i get fb kn the beginning of the loop, i dont have any flickering or lag anymore. Runs perfectly?
Does your app flicker?
So you get FB before entering the main loop, right?I do wait for a vblanc, and since i get fb kn the beginning of the loop, i dont have any flickering or lag anymore. Runs perfectly
So you get FB before entering the main loop, right?
void get_buffers() {
top = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
bottom = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
}
int main() {
bool change = true;
srvInit();
aptInit();
hidInit(NULL);
gfxInitDefault();
init();
get_buffers();
while (aptMainLoop())
{
gspWaitForVBlank();
hidScanInput();
u32 kDown;
kDown = hidKeysDown();
touchPosition touch;
hidTouchRead(&touch);
//should actually check keys here
if(change == true || check_keyboard_click(touch)) {
draw_keyboard(bottom);
gfxFlushBuffers();
change = true;
}
if(change) {
draw_menu();
gfxFlushBuffers();
gfxSwapBuffers();
get_buffers();
change = false;
}
//check keys
gfxFlushBuffers();
}
gfxExit();
hidExit();
aptExit();
srvExit();
return 0;
}
if(change == true || check_keyboard_click(touch)) {
draw_keyboard(bottom);
gfxFlushBuffers();
change = true;
}
if(change) {
draw_menu();
gfxFlushBuffers();
gfxSwapBuffers();
get_buffers();
change = false;
}
I don't understand a things in this piece of code:
Code:if(change == true || check_keyboard_click(touch)) { draw_keyboard(bottom); gfxFlushBuffers(); change = true; } if(change) { draw_menu(); gfxFlushBuffers(); gfxSwapBuffers(); get_buffers(); change = false; }
If "check" is true, the 3ds executes the code inside both the "if":
draw_keyboard(bottom);
gfxFlushBuffers();
change = true; check is already true, otherwise we wouldn't be running this code
draw_menu();
gfxFlushBuffers(); you flush again? Just do it one time!
gfxSwapBuffers();
get_buffers();
change = false;
I don't have the full code but *i think* there's something wrong here...
Yeah I understood that but...It's pretty simple actually,
But you don't have the full code,
Instead of the //check here for key presses part, i check if a key is pressed, and if it has been pressed then change = true;
Then, in the next frame.
If something changed (still only keypress), i want to redraw the keyboard, and the menu.
But if nothing changed, i'm gonna check if someone pressed the keyboard in a way something changed, if it does I need to redraw the keyboard + the menu
EDIT: It makes sense if you get the complete code, but the change variable has a wrong name,
Yeah I understood that but...
If change is true, it executes both the if.
If check_keyboard_click(touch) is true, it executes both the if.
If change is false, the two if's code won't get executed.
If check_keyboard_click(touch) is false, the two if's code won't get executed.
This means that those two "if" will behave the same, if one is executed, the other one is executed, if one isn't executed, the other one isn't executed. This means that those if can be merged in only one zip, with change || check_keyboard_click(touch) as condiction!
You're welcome!Good point, I though of that, but it was late will change that, thanks