ANDROID: implement OSystem methods and add support for soft rendering
This commit is contained in:
parent
8b784de736
commit
c501fa8c58
3 changed files with 179 additions and 106 deletions
|
@ -119,7 +119,9 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
|
||||||
_htc_fail(false),
|
_htc_fail(false),
|
||||||
_force_redraw(false),
|
_force_redraw(false),
|
||||||
_game_texture(0),
|
_game_texture(0),
|
||||||
|
_game_pbuf(),
|
||||||
_overlay_texture(0),
|
_overlay_texture(0),
|
||||||
|
_opengl(false),
|
||||||
_mouse_texture(0),
|
_mouse_texture(0),
|
||||||
_mouse_texture_palette(0),
|
_mouse_texture_palette(0),
|
||||||
_mouse_texture_rgb(0),
|
_mouse_texture_rgb(0),
|
||||||
|
@ -406,6 +408,9 @@ bool OSystem_Android::hasFeature(Feature f) {
|
||||||
f == kFeatureAspectRatioCorrection ||
|
f == kFeatureAspectRatioCorrection ||
|
||||||
f == kFeatureCursorPalette ||
|
f == kFeatureCursorPalette ||
|
||||||
f == kFeatureVirtualKeyboard ||
|
f == kFeatureVirtualKeyboard ||
|
||||||
|
#ifdef USE_OPENGL
|
||||||
|
f == kFeatureOpenGL ||
|
||||||
|
#endif
|
||||||
f == kFeatureOverlaySupportsAlpha);
|
f == kFeatureOverlaySupportsAlpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "audio/mixer_intern.h"
|
#include "audio/mixer_intern.h"
|
||||||
#include "graphics/palette.h"
|
#include "graphics/palette.h"
|
||||||
#include "graphics/surface.h"
|
#include "graphics/surface.h"
|
||||||
|
#include "graphics/pixelbuffer.h"
|
||||||
#include "backends/base-backend.h"
|
#include "backends/base-backend.h"
|
||||||
#include "backends/plugins/posix/posix-provider.h"
|
#include "backends/plugins/posix/posix-provider.h"
|
||||||
#include "backends/fs/posix/posix-fs-factory.h"
|
#include "backends/fs/posix/posix-fs-factory.h"
|
||||||
|
@ -116,8 +117,12 @@ private:
|
||||||
|
|
||||||
bool _force_redraw;
|
bool _force_redraw;
|
||||||
|
|
||||||
|
bool _opengl;
|
||||||
|
|
||||||
// Game layer
|
// Game layer
|
||||||
GLESBaseTexture *_game_texture;
|
GLESBaseTexture *_game_texture;
|
||||||
|
Graphics::PixelBuffer _game_pbuf;
|
||||||
|
|
||||||
int _shake_offset;
|
int _shake_offset;
|
||||||
Common::Rect _focus_rect;
|
Common::Rect _focus_rect;
|
||||||
|
|
||||||
|
@ -294,6 +299,11 @@ public:
|
||||||
virtual void addSysArchivesToSearchSet(Common::SearchSet &s,
|
virtual void addSysArchivesToSearchSet(Common::SearchSet &s,
|
||||||
int priority = 0);
|
int priority = 0);
|
||||||
virtual Common::String getSystemLanguage() const;
|
virtual Common::String getSystemLanguage() const;
|
||||||
|
|
||||||
|
// ResidualVM specific method
|
||||||
|
virtual void launcherInitSize(uint w, uint h);
|
||||||
|
bool lockMouse(bool lock);
|
||||||
|
Graphics::PixelBuffer setupScreen(int screenW, int screenH, bool fullscreen, bool accel3d);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -50,6 +50,17 @@ static inline GLfixed xdiv(int numerator, int denominator) {
|
||||||
return (numerator << 16) / denominator;
|
return (numerator << 16) / denominator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ResidualVM specific method
|
||||||
|
void OSystem_Android::launcherInitSize(uint w, uint h) {
|
||||||
|
//setupScreen(w, h, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResidualVM specific method
|
||||||
|
bool OSystem_Android::lockMouse(bool lock) {
|
||||||
|
_show_mouse = lock;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const OSystem::GraphicsMode *OSystem_Android::getSupportedGraphicsModes() const {
|
const OSystem::GraphicsMode *OSystem_Android::getSupportedGraphicsModes() const {
|
||||||
static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
|
static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
|
||||||
{ "default", "Default", 0 },
|
{ "default", "Default", 0 },
|
||||||
|
@ -222,24 +233,37 @@ void OSystem_Android::initViewport() {
|
||||||
|
|
||||||
assert(JNI::haveSurface());
|
assert(JNI::haveSurface());
|
||||||
|
|
||||||
|
if (_opengl) {
|
||||||
|
GLCALL(glEnable(GL_DITHER));
|
||||||
|
GLCALL(glShadeModel(GL_SMOOTH));
|
||||||
|
|
||||||
|
GLCALL(glDisableClientState(GL_VERTEX_ARRAY));
|
||||||
|
GLCALL(glDisableClientState(GL_TEXTURE_COORD_ARRAY));
|
||||||
|
|
||||||
|
GLCALL(glDisable(GL_TEXTURE_2D));
|
||||||
|
|
||||||
|
GLCALL(glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST));
|
||||||
|
} else {
|
||||||
// Turn off anything that looks like 3D ;)
|
// Turn off anything that looks like 3D ;)
|
||||||
GLCALL(glDisable(GL_CULL_FACE));
|
|
||||||
GLCALL(glDisable(GL_DEPTH_TEST));
|
|
||||||
GLCALL(glDisable(GL_LIGHTING));
|
|
||||||
GLCALL(glDisable(GL_FOG));
|
|
||||||
GLCALL(glDisable(GL_DITHER));
|
GLCALL(glDisable(GL_DITHER));
|
||||||
|
|
||||||
GLCALL(glShadeModel(GL_FLAT));
|
GLCALL(glShadeModel(GL_FLAT));
|
||||||
GLCALL(glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST));
|
|
||||||
|
|
||||||
GLCALL(glEnable(GL_BLEND));
|
|
||||||
GLCALL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
|
||||||
|
|
||||||
GLCALL(glEnableClientState(GL_VERTEX_ARRAY));
|
GLCALL(glEnableClientState(GL_VERTEX_ARRAY));
|
||||||
GLCALL(glEnableClientState(GL_TEXTURE_COORD_ARRAY));
|
GLCALL(glEnableClientState(GL_TEXTURE_COORD_ARRAY));
|
||||||
|
|
||||||
GLCALL(glEnable(GL_TEXTURE_2D));
|
GLCALL(glEnable(GL_TEXTURE_2D));
|
||||||
|
|
||||||
|
GLCALL(glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST));
|
||||||
|
}
|
||||||
|
|
||||||
|
GLCALL(glDisable(GL_CULL_FACE));
|
||||||
|
GLCALL(glDisable(GL_DEPTH_TEST));
|
||||||
|
GLCALL(glDisable(GL_LIGHTING));
|
||||||
|
GLCALL(glDisable(GL_FOG));
|
||||||
|
|
||||||
|
GLCALL(glEnable(GL_BLEND));
|
||||||
|
GLCALL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
||||||
|
|
||||||
GLCALL(glViewport(0, 0, _egl_surface_width, _egl_surface_height));
|
GLCALL(glViewport(0, 0, _egl_surface_width, _egl_surface_height));
|
||||||
|
|
||||||
GLCALL(glMatrixMode(GL_PROJECTION));
|
GLCALL(glMatrixMode(GL_PROJECTION));
|
||||||
|
@ -310,7 +334,11 @@ void OSystem_Android::clearScreen(FixupType type, byte count) {
|
||||||
for (byte i = 0; i < count; ++i) {
|
for (byte i = 0; i < count; ++i) {
|
||||||
// clear screen
|
// clear screen
|
||||||
GLCALL(glClearColorx(0, 0, 0, 1 << 16));
|
GLCALL(glClearColorx(0, 0, 0, 1 << 16));
|
||||||
|
if (_opengl) {
|
||||||
|
GLCALL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT));
|
||||||
|
} else {
|
||||||
GLCALL(glClear(GL_COLOR_BUFFER_BIT));
|
GLCALL(glClear(GL_COLOR_BUFFER_BIT));
|
||||||
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case kClear:
|
case kClear:
|
||||||
|
@ -430,6 +458,28 @@ void OSystem_Android::copyRectToScreen(const byte *buf, int pitch,
|
||||||
_game_texture->updateBuffer(x, y, w, h, buf, pitch);
|
_game_texture->updateBuffer(x, y, w, h, buf, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ResidualVM specific method
|
||||||
|
Graphics::PixelBuffer OSystem_Android::setupScreen(int screenW, int screenH, bool fullscreen, bool accel3d) {
|
||||||
|
_opengl = accel3d;
|
||||||
|
initViewport();
|
||||||
|
|
||||||
|
if (_opengl) {
|
||||||
|
// resize game texture
|
||||||
|
initSize(screenW, screenH, 0);
|
||||||
|
// format is not used by the gfx_opengl driver, use fake format
|
||||||
|
_game_pbuf.set(Graphics::PixelFormat(), 0);
|
||||||
|
} else {
|
||||||
|
Graphics::PixelFormat format = GLES565Texture::pixelFormat();
|
||||||
|
initSize(screenW, screenH, &format);
|
||||||
|
// as there is no support for the texture surface's lock/unlock mechanism in gfx_tinygl/...
|
||||||
|
// do not use _game_texture->surface()->pixels directly
|
||||||
|
_game_pbuf.create(_game_texture->getPixelFormat(),
|
||||||
|
_game_texture->width() * _game_texture->height(), DisposeAfterUse::YES);
|
||||||
|
}
|
||||||
|
return _game_pbuf;
|
||||||
|
}
|
||||||
|
|
||||||
void OSystem_Android::updateScreen() {
|
void OSystem_Android::updateScreen() {
|
||||||
//ENTER();
|
//ENTER();
|
||||||
|
|
||||||
|
@ -438,6 +488,13 @@ void OSystem_Android::updateScreen() {
|
||||||
if (!JNI::haveSurface())
|
if (!JNI::haveSurface())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!_opengl) {
|
||||||
|
if (_game_pbuf) {
|
||||||
|
int pitch = _game_texture->width() * _game_texture->getPixelFormat().bytesPerPixel;
|
||||||
|
_game_texture->updateBuffer(0, 0, _game_texture->width(), _game_texture->height(),
|
||||||
|
_game_pbuf.getRawBuffer(), pitch);
|
||||||
|
}
|
||||||
|
|
||||||
if (!_force_redraw &&
|
if (!_force_redraw &&
|
||||||
!_game_texture->dirty() &&
|
!_game_texture->dirty() &&
|
||||||
!_overlay_texture->dirty() &&
|
!_overlay_texture->dirty() &&
|
||||||
|
@ -541,6 +598,7 @@ void OSystem_Android::updateScreen() {
|
||||||
}
|
}
|
||||||
|
|
||||||
GLCALL(glPopMatrix());
|
GLCALL(glPopMatrix());
|
||||||
|
}
|
||||||
|
|
||||||
if (!JNI::swapBuffers())
|
if (!JNI::swapBuffers())
|
||||||
LOGW("swapBuffers failed: 0x%x", glGetError());
|
LOGW("swapBuffers failed: 0x%x", glGetError());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue