mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-25 01:00:01 +00:00
Add Google Cardboard Support
This commit is contained in:
parent
28cd190e0a
commit
b08c7012f1
@ -401,6 +401,10 @@ static int DefaultAndroidHwScale() {
|
||||
}
|
||||
|
||||
static ConfigSetting graphicsSettings[] = {
|
||||
ConfigSetting("EnableCardboard", &g_Config.bEnableCardboard, false, true, true),
|
||||
ConfigSetting("CardboardScreenSize", &g_Config.iCardboardScreenSize, 50, true, true),
|
||||
ConfigSetting("CardboardXShift", &g_Config.iCardboardXShift, 0, true, true),
|
||||
ConfigSetting("CardboardYShift", &g_Config.iCardboardXShift, 0, true, true),
|
||||
ConfigSetting("ShowFPSCounter", &g_Config.iShowFPSCounter, 0, true, true),
|
||||
ReportedConfigSetting("GPUBackend", &g_Config.iGPUBackend, 0),
|
||||
ReportedConfigSetting("RenderingMode", &g_Config.iRenderingMode, &DefaultRenderingMode, true, true),
|
||||
|
@ -152,6 +152,11 @@ public:
|
||||
bool bAutoFrameSkip;
|
||||
bool bFrameSkipUnthrottle;
|
||||
|
||||
bool bEnableCardboard; // Cardboard Master Switch
|
||||
int iCardboardScreenSize; // Screen Size (in %)
|
||||
int iCardboardXShift; // X-Shift of Screen (in %)
|
||||
int iCardboardYShift; // Y-Shift of Screen (in %)
|
||||
|
||||
int iWindowX;
|
||||
int iWindowY;
|
||||
int iWindowWidth; // Windows and other windowed environments
|
||||
|
@ -1069,10 +1069,32 @@ void FramebufferManager::CopyDisplayToOutput() {
|
||||
const float u1 = (480.0f + offsetX) / (float)vfb->bufferWidth;
|
||||
const float v1 = (272.0f + offsetY) / (float)vfb->bufferHeight;
|
||||
|
||||
// Cardboard Settings
|
||||
float cardboardScreenScale = g_Config.iCardboardScreenSize / 100.0f;
|
||||
float cardboardScreenWidth = PSP_CoreParameter().pixelWidth / 2.0f * cardboardScreenScale;
|
||||
float cardboardScreenHeight = PSP_CoreParameter().pixelHeight / 2.0f * cardboardScreenScale;
|
||||
float cardboardMaxXShift = (PSP_CoreParameter().pixelWidth / 2.0f - cardboardScreenWidth) / 2.0f;
|
||||
float cardboardUserXShift = g_Config.iCardboardXShift / 100.0f * cardboardMaxXShift;
|
||||
float cardboardLeftEyeX = cardboardMaxXShift + cardboardUserXShift;
|
||||
float cardboardRightEyeX = PSP_CoreParameter().pixelWidth / 2.0f + cardboardMaxXShift - cardboardUserXShift;
|
||||
float cardboardMaxYShift = PSP_CoreParameter().pixelHeight / 2.0f - cardboardScreenHeight / 2.0f;
|
||||
float cardboardUserYShift = g_Config.iCardboardYShift / 100.0f * cardboardMaxYShift;
|
||||
float cardboardScreenY = cardboardMaxYShift + cardboardUserYShift;
|
||||
|
||||
if (!usePostShader_) {
|
||||
glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
|
||||
// These are in the output display coordinates
|
||||
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1);
|
||||
if (g_Config.bEnableCardboard) {
|
||||
// Left Eye Image
|
||||
glstate.viewport.set(cardboardLeftEyeX, cardboardScreenY, cardboardScreenWidth, cardboardScreenHeight);
|
||||
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1);
|
||||
|
||||
// Right Eye Image
|
||||
glstate.viewport.set(cardboardRightEyeX, cardboardScreenY, cardboardScreenWidth, cardboardScreenHeight);
|
||||
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1);
|
||||
} else {
|
||||
// Fullscreen Image
|
||||
glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
|
||||
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1);
|
||||
}
|
||||
} else if (usePostShader_ && extraFBOs_.size() == 1 && !postShaderAtOutputResolution_) {
|
||||
// An additional pass, post-processing shader to the extra FBO.
|
||||
fbo_bind_as_render_target(extraFBOs_[0]);
|
||||
@ -1090,14 +1112,34 @@ void FramebufferManager::CopyDisplayToOutput() {
|
||||
return;
|
||||
}
|
||||
colorTexture = fbo_get_color_texture(extraFBOs_[0]);
|
||||
glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
|
||||
// These are in the output display coordinates
|
||||
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1);
|
||||
|
||||
if (g_Config.bEnableCardboard) {
|
||||
// Left Eye Image
|
||||
glstate.viewport.set(cardboardLeftEyeX, cardboardScreenY, cardboardScreenWidth, cardboardScreenHeight);
|
||||
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1);
|
||||
|
||||
// Right Eye Image
|
||||
glstate.viewport.set(cardboardRightEyeX, cardboardScreenY, cardboardScreenWidth, cardboardScreenHeight);
|
||||
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1);
|
||||
} else {
|
||||
// Fullscreen Image
|
||||
glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
|
||||
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1);
|
||||
}
|
||||
} else {
|
||||
// Use post-shader, but run shader at output resolution.
|
||||
glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
|
||||
// These are in the output display coordinates
|
||||
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1, postShaderProgram_);
|
||||
if (g_Config.bEnableCardboard) {
|
||||
// Left Eye Image
|
||||
glstate.viewport.set(cardboardLeftEyeX, cardboardScreenY, cardboardScreenWidth, cardboardScreenHeight);
|
||||
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1);
|
||||
|
||||
// Right Eye Image
|
||||
glstate.viewport.set(cardboardRightEyeX, cardboardScreenY, cardboardScreenWidth, cardboardScreenHeight);
|
||||
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1);
|
||||
} else {
|
||||
// Fullscreen Image
|
||||
glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
|
||||
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1, postShaderProgram_);
|
||||
}
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
@ -136,10 +136,21 @@ void GameSettingsScreen::CreateViews() {
|
||||
PopupMultiChoice *renderingModeChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iRenderingMode, gs->T("Mode"), renderingMode, 0, ARRAY_SIZE(renderingMode), gs, screenManager()));
|
||||
renderingModeChoice->OnChoice.Handle(this, &GameSettingsScreen::OnRenderingMode);
|
||||
renderingModeChoice->SetDisabledPtr(&g_Config.bSoftwareRendering);
|
||||
|
||||
CheckBox *blockTransfer = graphicsSettings->Add(new CheckBox(&g_Config.bBlockTransferGPU, gs->T("Simulate Block Transfer", "Simulate Block Transfer (unfinished)")));
|
||||
blockTransfer->SetDisabledPtr(&g_Config.bSoftwareRendering);
|
||||
|
||||
#ifdef ANDROID
|
||||
graphicsSettings->Add(new ItemHeader(gs->T("Cardboard Settings", "Cardboard Settings")));
|
||||
CheckBox *cardboardMode = graphicsSettings->Add(new CheckBox(&g_Config.bEnableCardboard, gs->T("Enable Cardboard", "Enable Cardboard")));
|
||||
cardboardMode->SetDisabledPtr(&g_Config.bSoftwareRendering);
|
||||
PopupSliderChoice * cardboardScreenSize = graphicsSettings->Add(new PopupSliderChoice(&g_Config.iCardboardScreenSize, 30, 100, gs->T("Cardboard Screen Size", "Screen Size (in % of the viewport)"), 1, screenManager()));
|
||||
cardboardScreenSize->SetDisabledPtr(&g_Config.bSoftwareRendering);
|
||||
PopupSliderChoice *cardboardXShift = graphicsSettings->Add(new PopupSliderChoice(&g_Config.iCardboardXShift, -100, 100, gs->T("Cardboard Screen X Shift", "X Shift (in % of the void)"), 1, screenManager()));
|
||||
cardboardXShift->SetDisabledPtr(&g_Config.bSoftwareRendering);
|
||||
PopupSliderChoice *cardboardYShift = graphicsSettings->Add(new PopupSliderChoice(&g_Config.iCardboardYShift, -100, 100, gs->T("Cardboard Screen Y Shift", "Y Shift (in % of the void)"), 1, screenManager()));
|
||||
cardboardYShift->SetDisabledPtr(&g_Config.bSoftwareRendering);
|
||||
#endif
|
||||
|
||||
graphicsSettings->Add(new ItemHeader(gs->T("Frame Rate Control")));
|
||||
static const char *frameSkip[] = {"Off", "1", "2", "3", "4", "5", "6", "7", "8"};
|
||||
graphicsSettings->Add(new PopupMultiChoice(&g_Config.iFrameSkip, gs->T("Frame Skipping"), frameSkip, 0, ARRAY_SIZE(frameSkip), gs, screenManager()));
|
||||
@ -312,6 +323,7 @@ void GameSettingsScreen::CreateViews() {
|
||||
// We normally use software rendering to debug so put it in debugging.
|
||||
CheckBox *softwareGPU = graphicsSettings->Add(new CheckBox(&g_Config.bSoftwareRendering, gs->T("Software Rendering", "Software Rendering (experimental)")));
|
||||
softwareGPU->OnClick.Handle(this, &GameSettingsScreen::OnSoftwareRendering);
|
||||
|
||||
if (PSP_IsInited() || g_Config.iGPUBackend != GPU_BACKEND_OPENGL)
|
||||
softwareGPU->SetEnabled(false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user