mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-22 10:39:18 +01:00
sync w/ screenshot code from snes9x-gx
This commit is contained in:
parent
4066768fd2
commit
9c933cf7df
@ -46,8 +46,8 @@ static GuiTrigger * trigA = NULL;
|
||||
static GuiTrigger * trig2 = NULL;
|
||||
|
||||
static GuiButton * btnLogo = NULL;
|
||||
static GuiImageData * gameScreen = NULL;
|
||||
static GuiImage * gameScreenImg = NULL;
|
||||
static GuiImage * bgImg = NULL;
|
||||
static GuiImage * bgTopImg = NULL;
|
||||
static GuiImage * bgBottomImg = NULL;
|
||||
static GuiSound * bgMusic = NULL;
|
||||
@ -816,11 +816,7 @@ static void WindowCredits(void * ptr)
|
||||
{
|
||||
UpdatePads();
|
||||
|
||||
if(gameScreenImg)
|
||||
gameScreenImg->Draw();
|
||||
else
|
||||
bgImg->Draw();
|
||||
|
||||
bgBottomImg->Draw();
|
||||
bgTopImg->Draw();
|
||||
creditsWindow.Draw();
|
||||
@ -1380,19 +1376,17 @@ static int MenuGame()
|
||||
{
|
||||
if (WindowPrompt("Quit Game", "Quit this game? Any unsaved progress will be lost.", "OK", "Cancel"))
|
||||
{
|
||||
if(gameScreenImg)
|
||||
{
|
||||
HaltGui();
|
||||
mainWindow->Remove(gameScreenImg);
|
||||
delete gameScreenImg;
|
||||
gameScreenImg = NULL;
|
||||
}
|
||||
if(gameScreenTex)
|
||||
{
|
||||
free(gameScreenTex);
|
||||
gameScreenTex = NULL;
|
||||
gameScreenPngSize = 0;
|
||||
}
|
||||
bgImg->SetVisible(true);
|
||||
delete gameScreen;
|
||||
gameScreen = NULL;
|
||||
free(gameScreenPng);
|
||||
gameScreenPng = NULL;
|
||||
gameScreenImg = new GuiImage(screenwidth, screenheight, (GXColor){236, 226, 238, 255});
|
||||
gameScreenImg->ColorStripe(10);
|
||||
mainWindow->Insert(gameScreenImg, 0);
|
||||
ResumeGui();
|
||||
#ifndef NO_SOUND
|
||||
bgMusic->Play(); // startup music
|
||||
#endif
|
||||
@ -4230,29 +4224,23 @@ MainMenu (int menu)
|
||||
|
||||
mainWindow = new GuiWindow(screenwidth, screenheight);
|
||||
|
||||
bgImg = new GuiImage(screenwidth, screenheight, (GXColor){236, 226, 238, 255});
|
||||
bgImg->ColorStripe(10);
|
||||
mainWindow->Append(bgImg);
|
||||
|
||||
if(gameScreenTex)
|
||||
if(menu == MENU_GAME)
|
||||
{
|
||||
IMGCTX pngContext = PNGU_SelectImageFromBuffer(gameScreenPng);
|
||||
|
||||
if (pngContext != NULL)
|
||||
{
|
||||
gameScreenPngSize = PNGU_EncodeFromGXTexture(pngContext, vmode->fbWidth, vmode->efbHeight, gameScreenTex, 0);
|
||||
PNGU_ReleaseImageContext(pngContext);
|
||||
DCFlushRange(gameScreenPng, 512*1024);
|
||||
}
|
||||
|
||||
gameScreenImg = new GuiImage(gameScreenTex, vmode->fbWidth, vmode->efbHeight);
|
||||
gameScreen = new GuiImageData(gameScreenPng);
|
||||
gameScreenImg = new GuiImage(gameScreen);
|
||||
gameScreenImg->SetAlpha(192);
|
||||
gameScreenImg->ColorStripe(30);
|
||||
|
||||
gameScreenImg->SetScaleX(screenwidth/(float)vmode->fbWidth);
|
||||
gameScreenImg->SetScaleY(screenheight/(float)vmode->efbHeight);
|
||||
mainWindow->Append(gameScreenImg);
|
||||
bgImg->SetVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
gameScreenImg = new GuiImage(screenwidth, screenheight, (GXColor){236, 226, 238, 255});
|
||||
gameScreenImg->ColorStripe(10);
|
||||
}
|
||||
|
||||
mainWindow->Append(gameScreenImg);
|
||||
|
||||
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM);
|
||||
GuiSound btnSoundClick(button_click_pcm, button_click_pcm_size, SOUND_PCM);
|
||||
@ -4394,23 +4382,20 @@ MainMenu (int menu)
|
||||
#endif
|
||||
|
||||
delete btnLogo;
|
||||
delete bgImg;
|
||||
delete gameScreenImg;
|
||||
delete bgTopImg;
|
||||
delete bgBottomImg;
|
||||
delete mainWindow;
|
||||
|
||||
mainWindow = NULL;
|
||||
|
||||
if(gameScreenImg)
|
||||
if(gameScreen)
|
||||
delete gameScreen;
|
||||
|
||||
if(gameScreenPng)
|
||||
{
|
||||
delete gameScreenImg;
|
||||
gameScreenImg = NULL;
|
||||
}
|
||||
if(gameScreenTex)
|
||||
{
|
||||
free(gameScreenTex);
|
||||
gameScreenTex = NULL;
|
||||
gameScreenPngSize = 0;
|
||||
free(gameScreenPng);
|
||||
gameScreenPng = NULL;
|
||||
}
|
||||
|
||||
// wait for keys to be depressed
|
||||
|
@ -354,7 +354,6 @@ bool SaveBatteryOrState(char * filepath, int action, bool silent)
|
||||
if(!FindDevice(filepath, &device))
|
||||
return 0;
|
||||
|
||||
// save screenshot - I would prefer to do this from gameScreenTex
|
||||
if(action == FILE_SNAPSHOT && gameScreenPngSize > 0)
|
||||
{
|
||||
char screenpath[1024];
|
||||
|
@ -35,7 +35,6 @@ int whichfb = 0; // Frame buffer toggle
|
||||
|
||||
static Mtx GXmodelView2D;
|
||||
|
||||
u8 * gameScreenTex = NULL; // a GX texture screen capture of the game
|
||||
u8 * gameScreenPng = NULL;
|
||||
int gameScreenPngSize = 0;
|
||||
|
||||
@ -674,16 +673,15 @@ void GX_Render(int width, int height, u8 * buffer, int pitch)
|
||||
***************************************************************************/
|
||||
void TakeScreenshot()
|
||||
{
|
||||
int texSize = vmode->fbWidth * vmode->efbHeight * 4;
|
||||
IMGCTX pngContext = PNGU_SelectImageFromBuffer(savebuffer);
|
||||
|
||||
if(gameScreenTex) free(gameScreenTex);
|
||||
gameScreenTex = (u8 *)memalign(32, texSize);
|
||||
if(gameScreenTex == NULL) return;
|
||||
GX_SetTexCopySrc(0, 0, vmode->fbWidth, vmode->efbHeight);
|
||||
GX_SetTexCopyDst(vmode->fbWidth, vmode->efbHeight, GX_TF_RGBA8, GX_FALSE);
|
||||
GX_CopyTex(gameScreenTex, GX_FALSE);
|
||||
GX_PixModeSync();
|
||||
DCFlushRange(gameScreenTex, texSize);
|
||||
if (pngContext != NULL)
|
||||
{
|
||||
gameScreenPngSize = PNGU_EncodeFromEFB(pngContext, vmode->fbWidth, vmode->efbHeight);
|
||||
PNGU_ReleaseImageContext(pngContext);
|
||||
gameScreenPng = (u8 *)malloc(gameScreenPngSize);
|
||||
memcpy(gameScreenPng, savebuffer, gameScreenPngSize);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user