IPHONE: Add support for unfiltered upscaling.
This commit is contained in:
parent
8102e7e645
commit
d77253fbe5
6 changed files with 64 additions and 20 deletions
|
@ -50,6 +50,11 @@ enum UIViewSwipeDirection {
|
||||||
kUIViewSwipeRight = 8
|
kUIViewSwipeRight = 8
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
kGraphicsModeLinear = 0,
|
||||||
|
kGraphicsModeNone = 1
|
||||||
|
} GraphicsModes;
|
||||||
|
|
||||||
#ifdef IPHONE_OFFICIAL
|
#ifdef IPHONE_OFFICIAL
|
||||||
void iphone_main(int argc, char **argv);
|
void iphone_main(int argc, char **argv);
|
||||||
#endif
|
#endif
|
||||||
|
@ -65,6 +70,7 @@ void iphone_main(int argc, char *argv[]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// On the ObjC side
|
// On the ObjC side
|
||||||
|
void iPhone_setGraphicsMode(int mode);
|
||||||
void iPhone_updateScreen(int mouseX, int mouseY);
|
void iPhone_updateScreen(int mouseX, int mouseY);
|
||||||
void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2);
|
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);
|
void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2);
|
||||||
|
|
|
@ -62,6 +62,8 @@
|
||||||
|
|
||||||
- (void)initSurface;
|
- (void)initSurface;
|
||||||
|
|
||||||
|
- (void)setGraphicsMode;
|
||||||
|
|
||||||
- (void)updateSurface;
|
- (void)updateSurface;
|
||||||
- (void)updateMainSurface;
|
- (void)updateMainSurface;
|
||||||
- (void)updateOverlaySurface;
|
- (void)updateOverlaySurface;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "iphone_common.h"
|
#include "iphone_common.h"
|
||||||
|
|
||||||
static iPhoneView *sharedInstance = nil;
|
static iPhoneView *sharedInstance = nil;
|
||||||
|
static GraphicsModes _graphicsMode = kGraphicsModeLinear;
|
||||||
static int _width = 0;
|
static int _width = 0;
|
||||||
static int _height = 0;
|
static int _height = 0;
|
||||||
static int _fullWidth;
|
static int _fullWidth;
|
||||||
|
@ -75,6 +76,12 @@ int printOglError(const char *file, int line) {
|
||||||
return retCode;
|
return retCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void iPhone_setGraphicsMode(int mode) {
|
||||||
|
_graphicsMode = mode;
|
||||||
|
|
||||||
|
[sharedInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES];
|
||||||
|
}
|
||||||
|
|
||||||
void iPhone_showCursor(int state) {
|
void iPhone_showCursor(int state) {
|
||||||
_mouseCursorEnabled = state;
|
_mouseCursorEnabled = state;
|
||||||
}
|
}
|
||||||
|
@ -201,6 +208,27 @@ bool getLocalMouseCoords(CGPoint *point) {
|
||||||
return true;
|
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
|
@implementation iPhoneView
|
||||||
|
|
||||||
|
@ -263,6 +291,12 @@ bool getLocalMouseCoords(CGPoint *point) {
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setGraphicsMode {
|
||||||
|
setFilterModeForTexture(_screenTexture, _graphicsMode);
|
||||||
|
setFilterModeForTexture(_overlayTexture, _graphicsMode);
|
||||||
|
setFilterModeForTexture(_mouseCursorTexture, _graphicsMode);
|
||||||
|
}
|
||||||
|
|
||||||
- (void)updateSurface {
|
- (void)updateSurface {
|
||||||
if (!_needsScreenUpdate) {
|
if (!_needsScreenUpdate) {
|
||||||
return;
|
return;
|
||||||
|
@ -287,9 +321,7 @@ bool getLocalMouseCoords(CGPoint *point) {
|
||||||
-(void)updateMouseCursor {
|
-(void)updateMouseCursor {
|
||||||
if (_mouseCursorTexture == 0) {
|
if (_mouseCursorTexture == 0) {
|
||||||
glGenTextures(1, &_mouseCursorTexture); printOpenGLError();
|
glGenTextures(1, &_mouseCursorTexture); printOpenGLError();
|
||||||
glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError();
|
setFilterModeForTexture(_mouseCursorTexture, _graphicsMode);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); printOpenGLError();
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); printOpenGLError();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError();
|
glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError();
|
||||||
|
@ -487,18 +519,14 @@ bool getLocalMouseCoords(CGPoint *point) {
|
||||||
}
|
}
|
||||||
|
|
||||||
glGenTextures(1, &_screenTexture); printOpenGLError();
|
glGenTextures(1, &_screenTexture); printOpenGLError();
|
||||||
glBindTexture(GL_TEXTURE_2D, _screenTexture); printOpenGLError();
|
setFilterModeForTexture(_screenTexture, _graphicsMode);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); printOpenGLError();
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); printOpenGLError();
|
|
||||||
|
|
||||||
if (_overlayTexture > 0) {
|
if (_overlayTexture > 0) {
|
||||||
glDeleteTextures(1, &_overlayTexture); printOpenGLError();
|
glDeleteTextures(1, &_overlayTexture); printOpenGLError();
|
||||||
}
|
}
|
||||||
|
|
||||||
glGenTextures(1, &_overlayTexture); printOpenGLError();
|
glGenTextures(1, &_overlayTexture); printOpenGLError();
|
||||||
glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError();
|
setFilterModeForTexture(_overlayTexture, _graphicsMode);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); printOpenGLError();
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); printOpenGLError();
|
|
||||||
|
|
||||||
if (_textureBuffer) {
|
if (_textureBuffer) {
|
||||||
free(_textureBuffer);
|
free(_textureBuffer);
|
||||||
|
|
|
@ -45,7 +45,9 @@
|
||||||
|
|
||||||
|
|
||||||
const OSystem::GraphicsMode OSystem_IPHONE::s_supportedGraphicsModes[] = {
|
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;
|
AQCallbackStruct OSystem_IPHONE::s_AudioQueue;
|
||||||
|
@ -60,7 +62,8 @@ OSystem_IPHONE::OSystem_IPHONE() :
|
||||||
_screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false),
|
_screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false),
|
||||||
_gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false),
|
_gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false),
|
||||||
_mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0),
|
_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;
|
_queuedInputEvent.type = Common::EVENT_INVALID;
|
||||||
_touchpadModeEnabled = !iPhone_isHighResDevice();
|
_touchpadModeEnabled = !iPhone_isHighResDevice();
|
||||||
_fsFactory = new POSIXFilesystemFactory();
|
_fsFactory = new POSIXFilesystemFactory();
|
||||||
|
|
|
@ -54,12 +54,13 @@ struct AQCallbackStruct {
|
||||||
|
|
||||||
class OSystem_IPHONE : public EventsBaseBackend, public PaletteManager {
|
class OSystem_IPHONE : public EventsBaseBackend, public PaletteManager {
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
static const OSystem::GraphicsMode s_supportedGraphicsModes[];
|
static const OSystem::GraphicsMode s_supportedGraphicsModes[];
|
||||||
static AQCallbackStruct s_AudioQueue;
|
static AQCallbackStruct s_AudioQueue;
|
||||||
static SoundProc s_soundCallback;
|
static SoundProc s_soundCallback;
|
||||||
static void *s_soundParam;
|
static void *s_soundParam;
|
||||||
|
|
||||||
|
int _currentGraphicsMode;
|
||||||
|
|
||||||
Audio::MixerImpl *_mixer;
|
Audio::MixerImpl *_mixer;
|
||||||
|
|
||||||
Graphics::Surface _framebuffer;
|
Graphics::Surface _framebuffer;
|
||||||
|
@ -129,7 +130,6 @@ public:
|
||||||
virtual bool getFeatureState(Feature f);
|
virtual bool getFeatureState(Feature f);
|
||||||
virtual const GraphicsMode *getSupportedGraphicsModes() const;
|
virtual const GraphicsMode *getSupportedGraphicsModes() const;
|
||||||
virtual int getDefaultGraphicsMode() const;
|
virtual int getDefaultGraphicsMode() const;
|
||||||
bool setGraphicsMode(const char *name);
|
|
||||||
virtual bool setGraphicsMode(int mode);
|
virtual bool setGraphicsMode(int mode);
|
||||||
virtual int getGraphicsMode() const;
|
virtual int getGraphicsMode() const;
|
||||||
virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format);
|
virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format);
|
||||||
|
|
|
@ -31,19 +31,24 @@ const OSystem::GraphicsMode *OSystem_IPHONE::getSupportedGraphicsModes() const {
|
||||||
|
|
||||||
|
|
||||||
int OSystem_IPHONE::getDefaultGraphicsMode() const {
|
int OSystem_IPHONE::getDefaultGraphicsMode() const {
|
||||||
return -1;
|
return kGraphicsModeLinear;
|
||||||
}
|
|
||||||
|
|
||||||
bool OSystem_IPHONE::setGraphicsMode(const char *mode) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OSystem_IPHONE::setGraphicsMode(int mode) {
|
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 {
|
int OSystem_IPHONE::getGraphicsMode() const {
|
||||||
return -1;
|
return _currentGraphicsMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) {
|
void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue