GP32 Screen Buffering


ConsoleTom

Member
Joined
Dec 4, 2003
Messages
106
Age
47
Location
Germany
Website
Visit site
Hi !

Let's say, i have a background picture and by pressing a button, a menu appears.

Now i would like to save the background picture to a buffer and show it again after closing the menu.

(I dont need a solution to the menu problem but how to save screens and show them again)

Greetings

Tobias

Thanks in ADVANCE ;)
 
if the menus pretty simple, and your using a standard double-buffer setup - simply draw the menu straight to the display, therefore leaving the back buffer clean to be flipped another day.

a problem with pasting a menu over the screen is, if all the buffers have a slightly different version of the screen (ie - character is moved by 1 pixel) he'll shake like crazy while the menus loaded.
 
memcpy( destination, source, length);

So if you wanted to copy framebuffer 2 into framebuffer 1, and it's 16 bit, you'd have to do:

memcpy(framebuffer1,framebuffer2,(320*240*2));
 
from GPAmp (16bit mode):

Code:
u16 *screenStack[256];
int screenStackPointer=0;

void saveScreen() {
	// get the current page
	u16 *screen = getCurrentPage();
	
	// malloc some mem to backup the screen to
	u16 *backup = (u16*)gm_malloc(320*240*2);

	// copy the current screen to backup mem
	gm_memcpy(backup,screen,76800*2);

	// push the saved screen on the screenstack
	screenStack[screenStackPointer++] = backup;
}


void restoreScreen() {
	// get the current page
	u16 *screen = getCurrentPage();
	
	// pop the previously saved screen from the screenstack
	u16 *backup = screenStack[--screenStackPointer];

	// copy the backup mem to current screen
	gm_memcpy(screen,backup,76800*2);

	// free backup memory
	gm_free(backup);

}
 
Back
Top