diff options
Diffstat (limited to 'backends')
-rw-r--r-- | backends/platform/iphone/iphone_common.h | 6 | ||||
-rw-r--r-- | backends/platform/iphone/iphone_video.h | 2 | ||||
-rw-r--r-- | backends/platform/iphone/iphone_video.m | 46 | ||||
-rw-r--r-- | backends/platform/iphone/osys_main.cpp | 7 | ||||
-rw-r--r-- | backends/platform/iphone/osys_main.h | 4 | ||||
-rw-r--r-- | backends/platform/iphone/osys_video.cpp | 19 |
6 files changed, 64 insertions, 20 deletions
diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 2c573656a6..75a83a067b 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -50,6 +50,11 @@ enum UIViewSwipeDirection { kUIViewSwipeRight = 8 }; +typedef enum { + kGraphicsModeLinear = 0, + kGraphicsModeNone = 1 +} GraphicsModes; + #ifdef IPHONE_OFFICIAL void iphone_main(int argc, char **argv); #endif @@ -65,6 +70,7 @@ void iphone_main(int argc, char *argv[]); #endif // On the ObjC side +void iPhone_setGraphicsMode(int mode); void iPhone_updateScreen(int mouseX, int mouseY); void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2); void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2); diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 25208deaaf..f484ebbb9e 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -62,6 +62,8 @@ - (void)initSurface; +- (void)setGraphicsMode; + - (void)updateSurface; - (void)updateMainSurface; - (void)updateOverlaySurface; diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index c1633841f5..2723cae23a 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -24,6 +24,7 @@ #include "iphone_common.h" static iPhoneView *sharedInstance = nil; +static GraphicsModes _graphicsMode = kGraphicsModeLinear; static int _width = 0; static int _height = 0; static int _fullWidth; @@ -75,6 +76,12 @@ int printOglError(const char *file, int line) { return retCode; } +void iPhone_setGraphicsMode(int mode) { + _graphicsMode = mode; + + [sharedInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES]; +} + void iPhone_showCursor(int state) { _mouseCursorEnabled = state; } @@ -201,6 +208,27 @@ bool getLocalMouseCoords(CGPoint *point) { return true; } +static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { + if (!tex) + return; + + glBindTexture(GL_TEXTURE_2D, tex); printOpenGLError(); + + GLint filter = GL_LINEAR; + + switch (mode) { + case kGraphicsModeLinear: + filter = GL_LINEAR; + break; + + case kGraphicsModeNone: + filter = GL_NEAREST; + break; + } + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); printOpenGLError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); printOpenGLError(); +} @implementation iPhoneView @@ -263,6 +291,12 @@ bool getLocalMouseCoords(CGPoint *point) { // } } +- (void)setGraphicsMode { + setFilterModeForTexture(_screenTexture, _graphicsMode); + setFilterModeForTexture(_overlayTexture, _graphicsMode); + setFilterModeForTexture(_mouseCursorTexture, _graphicsMode); +} + - (void)updateSurface { if (!_needsScreenUpdate) { return; @@ -287,9 +321,7 @@ bool getLocalMouseCoords(CGPoint *point) { -(void)updateMouseCursor { if (_mouseCursorTexture == 0) { glGenTextures(1, &_mouseCursorTexture); printOpenGLError(); - glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); printOpenGLError(); + setFilterModeForTexture(_mouseCursorTexture, _graphicsMode); } glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); @@ -487,18 +519,14 @@ bool getLocalMouseCoords(CGPoint *point) { } glGenTextures(1, &_screenTexture); printOpenGLError(); - glBindTexture(GL_TEXTURE_2D, _screenTexture); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); printOpenGLError(); + setFilterModeForTexture(_screenTexture, _graphicsMode); if (_overlayTexture > 0) { glDeleteTextures(1, &_overlayTexture); printOpenGLError(); } glGenTextures(1, &_overlayTexture); printOpenGLError(); - glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); printOpenGLError(); + setFilterModeForTexture(_overlayTexture, _graphicsMode); if (_textureBuffer) { free(_textureBuffer); diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 06b32270f4..3395ea6e56 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -45,7 +45,9 @@ const OSystem::GraphicsMode OSystem_IPHONE::s_supportedGraphicsModes[] = { - {0, 0, 0} + { "linear", "Linear filtering", kGraphicsModeLinear }, + { "none", "No filtering", kGraphicsModeNone }, + { 0, 0, 0 } }; AQCallbackStruct OSystem_IPHONE::s_AudioQueue; @@ -60,7 +62,8 @@ OSystem_IPHONE::OSystem_IPHONE() : _screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false), _gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false), _mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0), - _overlayHeight(0), _overlayWidth(0), _overlayBuffer(0), _mouseCursorPaletteEnabled(false) { + _overlayHeight(0), _overlayWidth(0), _overlayBuffer(0), _mouseCursorPaletteEnabled(false), + _currentGraphicsMode(kGraphicsModeLinear) { _queuedInputEvent.type = Common::EVENT_INVALID; _touchpadModeEnabled = !iPhone_isHighResDevice(); _fsFactory = new POSIXFilesystemFactory(); diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 61816cfa35..e4b3d358d5 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -54,12 +54,13 @@ struct AQCallbackStruct { class OSystem_IPHONE : public EventsBaseBackend, public PaletteManager { protected: - static const OSystem::GraphicsMode s_supportedGraphicsModes[]; static AQCallbackStruct s_AudioQueue; static SoundProc s_soundCallback; static void *s_soundParam; + int _currentGraphicsMode; + Audio::MixerImpl *_mixer; Graphics::Surface _framebuffer; @@ -129,7 +130,6 @@ public: virtual bool getFeatureState(Feature f); virtual const GraphicsMode *getSupportedGraphicsModes() const; virtual int getDefaultGraphicsMode() const; - bool setGraphicsMode(const char *name); virtual bool setGraphicsMode(int mode); virtual int getGraphicsMode() const; virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format); diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index 0483c72949..78c6cd4625 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -31,19 +31,24 @@ const OSystem::GraphicsMode *OSystem_IPHONE::getSupportedGraphicsModes() const { int OSystem_IPHONE::getDefaultGraphicsMode() const { - return -1; -} - -bool OSystem_IPHONE::setGraphicsMode(const char *mode) { - return true; + return kGraphicsModeLinear; } bool OSystem_IPHONE::setGraphicsMode(int mode) { - return true; + switch (mode) { + case kGraphicsModeNone: + case kGraphicsModeLinear: + _currentGraphicsMode = mode; + iPhone_setGraphicsMode(mode); + return true; + + default: + return false; + } } int OSystem_IPHONE::getGraphicsMode() const { - return -1; + return _currentGraphicsMode; } void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) { |