From 1aa3cf12c85607f4d3ef908b541c8e1992334cf2 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 28 Feb 2011 18:02:21 +0000 Subject: [PATCH] Work around a bug in the Android emulator that doesn't let us query the current viewport settings. --- src/video.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/video.cpp b/src/video.cpp index f8a9010a..3291b4b6 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -26,6 +26,10 @@ namespace lol { +#if defined ANDROID_NDK +vec2i saved_viewport; +#endif + #if defined HAVE_GL_2X || defined HAVE_GLES_2X Shader *stdshader; #endif @@ -96,6 +100,10 @@ void Video::Setup(int width, int height) /* Initialise OpenGL */ glViewport(0, 0, width, height); +#if defined ANDROID_NDK + saved_viewport = vec2i(width, height); +#endif + glClearColor(0.1f, 0.2f, 0.3f, 0.0f); glClearDepthf(1.0); @@ -223,16 +231,24 @@ void Video::Capture(uint32_t *buffer) int Video::GetWidth() { +#if defined ANDROID_NDK + return saved_viewport.x; +#else GLint v[4]; glGetIntegerv(GL_VIEWPORT, v); return v[2]; +#endif } int Video::GetHeight() { +#if defined ANDROID_NDK + return saved_viewport.y; +#else GLint v[4]; glGetIntegerv(GL_VIEWPORT, v); return v[3]; +#endif } } /* namespace lol */