Experimental: Make orientation change possible on Android.

This commit is contained in:
Henrik Rydgard 2013-07-16 22:50:53 +02:00
parent e370723c6c
commit 81411a74ed
10 changed files with 66 additions and 37 deletions

View File

@ -351,7 +351,6 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena
if (!Memory_TryBase(base, views, num_views, flags, arena))
{
PanicAlert("MemoryMap_Setup: Failed finding a memory base.");
exit(0);
return 0;
}
#else
@ -377,7 +376,6 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena
if (!Memory_TryBase(arena->memmap->Base(), views, num_views, flags, arena))
{
PanicAlert("MemoryMap_Setup: Failed finding a memory base.");
exit(0);
return 0;
}
u8* base = arena->memmap->Base();
@ -387,7 +385,6 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena
if (!Memory_TryBase(base, views, num_views, flags, arena))
{
PanicAlert("MemoryMap_Setup: Failed finding a memory base.");
exit(0);
return 0;
}
#endif

View File

@ -133,6 +133,16 @@ void CenterRect(float *x, float *y, float *w, float *h,
}
}
void FramebufferManager::CompileDraw2DProgram() {
if (!draw2dprogram) {
draw2dprogram = glsl_create_source(basic_vs, tex_fs);
glsl_bind(draw2dprogram);
glUniform1i(draw2dprogram->sampler0, 0);
glsl_unbind();
}
}
FramebufferManager::FramebufferManager() :
ramDisplayFramebufPtr_(0),
displayFramebufPtr_(0),
@ -145,18 +155,15 @@ FramebufferManager::FramebufferManager() :
currentRenderVfb_(0),
drawPixelsTex_(0),
drawPixelsTexFormat_(-1),
convBuf(0)
convBuf(0),
draw2dprogram(0)
#ifndef USING_GLES2
,
pixelBufObj_(0),
currentPBO_(0)
#endif
{
draw2dprogram = glsl_create_source(basic_vs, tex_fs);
glsl_bind(draw2dprogram);
glUniform1i(draw2dprogram->sampler0, 0);
glsl_unbind();
CompileDraw2DProgram();
// And an initial clear. We don't clear per frame as the games are supposed to handle that
// by themselves.
@ -197,7 +204,9 @@ FramebufferManager::FramebufferManager() :
FramebufferManager::~FramebufferManager() {
if (drawPixelsTex_)
glDeleteTextures(1, &drawPixelsTex_);
glsl_destroy(draw2dprogram);
if (draw2dprogram) {
glsl_destroy(draw2dprogram);
}
#ifndef USING_GLES2
delete [] pixelBufObj_;
@ -316,8 +325,9 @@ void FramebufferManager::DrawActiveTexture(float x, float y, float w, float h, b
const float pos[12] = {x,y,0, x+w,y,0, x+w,y+h,0, x,y+h,0};
const float texCoords[8] = {0,v1, u2,v1, u2,v2, 0,v2};
const GLubyte indices[4] = {0,1,3,2};
if(!program) {
CompileDraw2DProgram();
program = draw2dprogram;
}
@ -824,6 +834,8 @@ void FramebufferManager::BlitFramebuffer_(VirtualFramebuffer *src, VirtualFrameb
float x, y, w, h;
CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight);
CompileDraw2DProgram();
DrawActiveTexture(x, y, w, h, flip, upscale, vscale, draw2dprogram);
glBindTexture(GL_TEXTURE_2D, 0);
@ -1081,6 +1093,8 @@ void FramebufferManager::EndFrame() {
void FramebufferManager::DeviceLost() {
DestroyAllFBOs();
glsl_destroy(draw2dprogram);
draw2dprogram = 0;
resized_ = false;
}

View File

@ -152,6 +152,8 @@ public:
void DestroyFramebuf(VirtualFramebuffer *vfb);
private:
void CompileDraw2DProgram();
u32 ramDisplayFramebufPtr_; // workaround for MotoGP insanity
u32 displayFramebufPtr_;
u32 displayStride_;

View File

@ -460,6 +460,8 @@ void ShaderManager::Clear() {
fsCache.clear();
vsCache.clear();
globalDirty = 0xFFFFFFFF;
lastFSID.clear();
lastVSID.clear();
DirtyShader();
}
@ -473,6 +475,8 @@ void ShaderManager::DirtyShader() {
lastFSID.clear();
lastVSID.clear();
lastShader = 0;
globalDirty = 0xFFFFFFFF;
shaderSwitchDirty = 0;
}
void ShaderManager::EndFrame() { // disables vertex arrays

View File

@ -348,6 +348,12 @@ static const struct { int from, to; } legacy_touch_mapping[12] = {
};
void EmuScreen::update(InputState &input) {
// Simply forcibily update to the current screen size every frame. Doesn't cost much.
PSP_CoreParameter().outputWidth = dp_xres;
PSP_CoreParameter().outputHeight = dp_yres;
PSP_CoreParameter().pixelWidth = pixel_xres;
PSP_CoreParameter().pixelHeight = pixel_yres;
globalUIState = UISTATE_INGAME;
if (errorMessage_.size()) {
screenManager()->push(new PromptScreen(

View File

@ -90,8 +90,7 @@ void LayoutGamepad(int w, int h)
leftStick.setPos(stickX, stickY, controlScale);
}
void UpdateGamepad(InputState &input_state)
{
void UpdateGamepad(InputState &input_state) {
LayoutGamepad(dp_xres, dp_yres);
buttonO.update(input_state);
@ -119,8 +118,7 @@ void UpdateGamepad(InputState &input_state)
leftStick.update(input_state);
}
void DrawGamepad(DrawBuffer &db, float opacity)
{
void DrawGamepad(DrawBuffer &db, float opacity) {
uint32_t color = colorAlpha(0xc0b080, opacity);
uint32_t colorOverlay = colorAlpha(0xFFFFFF, opacity);

View File

@ -367,11 +367,7 @@ void NativeInit(int argc, const char *argv[],
SaveState::Load(stateToLoad);
g_gameInfoCache.Init();
}
void NativeInitGraphics() {
gl_lost_manager_init();
ui_draw2d.SetAtlas(&ui_atlas);
screenManager = new ScreenManager();
@ -388,6 +384,12 @@ void NativeInitGraphics() {
// Go directly into the game.
screenManager->switchScreen(new EmuScreen(boot_filename));
}
}
void NativeInitGraphics() {
gl_lost_manager_init();
ui_draw2d.SetAtlas(&ui_atlas);
UIShader_Init();
@ -450,6 +452,25 @@ void NativeInitGraphics() {
glstate.viewport.set(0, 0, pixel_xres, pixel_yres);
}
void NativeShutdownGraphics() {
screenManager->deviceLost();
g_gameInfoCache.Clear();
delete uiTexture;
uiTexture = NULL;
delete uiContext;
uiContext = NULL;
ui_draw2d.Shutdown();
ui_draw2d_front.Shutdown();
UIShader_Shutdown();
gl_lost_manager_shutdown();
}
void TakeScreenshot() {
#ifdef _WIN32
g_TakeScreenshot = false;
@ -573,25 +594,12 @@ void NativeMessageReceived(const char *message, const char *value) {
}
}
void NativeShutdownGraphics() {
g_gameInfoCache.Clear();
delete uiTexture;
uiTexture = NULL;
void NativeShutdown() {
screenManager->shutdown();
delete screenManager;
screenManager = 0;
ui_draw2d.Shutdown();
ui_draw2d_front.Shutdown();
UIShader_Shutdown();
gl_lost_manager_shutdown();
}
void NativeShutdown() {
g_gameInfoCache.Shutdown();
delete host;
@ -604,6 +612,7 @@ void NativeShutdown() {
// boot up correctly with "dirty" global variables currently, so we hack around that
// by simply exiting.
#ifdef ANDROID
ELOG("NativeShutdown called");
exit(0);
#endif
}

View File

@ -29,8 +29,7 @@
android:name=".PpssppActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation|locale|keyboard|keyboardHidden|navigation|fontScale|uiMode"
android:screenOrientation="landscape" >
android:configChanges="orientation|locale|keyboard|keyboardHidden|navigation|fontScale|uiMode">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

View File

@ -26,7 +26,7 @@ LOCAL_MODULE := ppsspp_jni
NATIVE := ../../native
SRC := ../..
LOCAL_CFLAGS := -DUSE_FFMPEG -DUSE_PROFILER -DGL_GLEXT_PROTOTYPES -DUSING_GLES2 -O3 -fsigned-char -Wall -Wno-multichar -Wno-psabi -Wno-unused-variable -fno-strict-aliasing -ffast-math
LOCAL_CFLAGS := -DUSE_FFMPEG -DUSE_PROFILER -DGL_GLEXT_PROTOTYPES -DUSING_GLES2 -O0 -g -fsigned-char -Wall -Wno-multichar -Wno-psabi -Wno-unused-variable -fno-strict-aliasing -ffast-math
# yes, it's really CPPFLAGS for C++
LOCAL_CPPFLAGS := -std=gnu++11 -fno-rtti
LOCAL_C_INCLUDES := \

2
native

@ -1 +1 @@
Subproject commit a7b92d63d6a51f41b3fe8c89fee0bd5f85b8f4a6
Subproject commit 8559d298f86338c779dee368249edc7087d8dd46