Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 87 additions & 45 deletions addons/ofxiOS/src/app/ofAppiOSWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,44 @@
class ofiOSWindowSettings: public ofGLESWindowSettings{
public:
ofiOSWindowSettings()
:enableRetina(false)
:enableRetina(true)
,retinaScale(0)
,enableDepth(false)
,enableAntiAliasing(false)
,numOfAntiAliasingSamples(0)
,enableHardwareOrientation(false)
,enableHardwareOrientationAnimation(false)
,enableSetupScreen(true) {
,enableSetupScreen(true)
,windowControllerType(ofxiOSWindowControllerType::CORE_ANIMATION)
,colorType(ofxiOSRendererColorFormat::RGBA8888)
,depthType(ofxiOSRendererDepthFormat::DEPTH_NONE)
,stencilType(ofxiOSRendererStencilFormat::STENCIL_NONE)
,enableMultiTouch(false) {
windowMode = OF_FULLSCREEN;
setupOrientation = OF_ORIENTATION_DEFAULT;
glesVersion = 1;
setupOrientation = OF_ORIENTATION_DEFAULT;
glesVersion = 2;
}

ofiOSWindowSettings(const ofWindowSettings & settings)
:ofGLESWindowSettings(settings)
,enableRetina(false)
,enableRetina(true)
,retinaScale(0)
,enableDepth(false)
,enableAntiAliasing(false)
,numOfAntiAliasingSamples(0)
,enableHardwareOrientation(false)
,enableHardwareOrientationAnimation(false)
,enableSetupScreen(true) {
,enableSetupScreen(true)
,windowControllerType(ofxiOSWindowControllerType::CORE_ANIMATION)
,colorType(ofxiOSRendererColorFormat::RGBA8888)
,depthType(ofxiOSRendererDepthFormat::DEPTH_NONE)
,stencilType(ofxiOSRendererStencilFormat::STENCIL_NONE)
,enableMultiTouch(false) {
const ofGLESWindowSettings * glesSettings = dynamic_cast<const ofGLESWindowSettings*>(&settings);
if(glesSettings){
glesVersion = glesSettings->glesVersion;
} else {
glesVersion = 1;
glesVersion = 2;
}
const ofiOSWindowSettings * iosSettings = dynamic_cast<const ofiOSWindowSettings*>(&settings);
if(iosSettings){
Expand All @@ -77,30 +87,45 @@ class ofiOSWindowSettings: public ofGLESWindowSettings{
enableHardwareOrientation = iosSettings->enableHardwareOrientation;
enableHardwareOrientationAnimation = iosSettings->enableHardwareOrientationAnimation;
enableSetupScreen = iosSettings->enableSetupScreen;
setupOrientation = iosSettings->setupOrientation;
setupOrientation = iosSettings->setupOrientation;
windowControllerType = iosSettings->windowControllerType;
colorType = iosSettings->colorType;
depthType = iosSettings->depthType;
stencilType = iosSettings->stencilType;
enableMultiTouch = iosSettings->enableMultiTouch;
} else {
enableRetina = false;
enableRetina = true;
retinaScale = 0;
enableDepth = false;
enableAntiAliasing = false;
numOfAntiAliasingSamples = 0;
enableHardwareOrientation = false;
enableHardwareOrientationAnimation = false;
enableSetupScreen = true;
setupOrientation = OF_ORIENTATION_DEFAULT;
setupOrientation = OF_ORIENTATION_DEFAULT;
windowControllerType = windowControllerType;
colorType = ofxiOSRendererColorFormat::RGBA8888;
depthType = ofxiOSRendererDepthFormat::DEPTH_NONE;
stencilType = ofxiOSRendererStencilFormat::STENCIL_NONE;
enableMultiTouch = false;
}
}

ofiOSWindowSettings(const ofGLESWindowSettings & settings)
:ofGLESWindowSettings(settings)
,enableRetina(false)
,enableRetina(true)
,retinaScale(0)
,enableDepth(false)
,enableAntiAliasing(false)
,numOfAntiAliasingSamples(0)
,enableHardwareOrientation(false)
,enableHardwareOrientationAnimation(false)
,enableSetupScreen(true) {
,enableSetupScreen(true)
,windowControllerType(ofxiOSWindowControllerType::CORE_ANIMATION)
,colorType(ofxiOSRendererColorFormat::RGBA8888)
,depthType(ofxiOSRendererDepthFormat::DEPTH_NONE)
,stencilType(ofxiOSRendererStencilFormat::STENCIL_NONE)
,enableMultiTouch(false){
const ofiOSWindowSettings * iosSettings = dynamic_cast<const ofiOSWindowSettings*>(&settings);
if(iosSettings){
enableRetina = iosSettings->enableRetina;
Expand All @@ -111,7 +136,12 @@ class ofiOSWindowSettings: public ofGLESWindowSettings{
enableHardwareOrientation = iosSettings->enableHardwareOrientation;
enableHardwareOrientationAnimation = iosSettings->enableHardwareOrientationAnimation;
enableSetupScreen = iosSettings->enableSetupScreen;
setupOrientation = iosSettings->setupOrientation;
setupOrientation = iosSettings->setupOrientation;
windowControllerType = iosSettings->windowControllerType;
colorType = iosSettings->colorType;
depthType = iosSettings->depthType;
stencilType = iosSettings->stencilType;
enableMultiTouch = iosSettings->enableMultiTouch;
}
}

Expand All @@ -125,18 +155,23 @@ class ofiOSWindowSettings: public ofGLESWindowSettings{
bool enableHardwareOrientation;
bool enableHardwareOrientationAnimation;
bool enableSetupScreen;
ofOrientation setupOrientation;

bool enableMultiTouch;
ofxiOSWindowControllerType windowControllerType;
ofxiOSRendererColorFormat colorType;
ofxiOSRendererDepthFormat depthType;
ofxiOSRendererStencilFormat stencilType;
ofOrientation setupOrientation;

};


class ofAppiOSWindow : public ofAppBaseGLESWindow {
public:

static ofAppiOSWindow * getInstance();
ofAppiOSWindow();
~ofAppiOSWindow();
ofAppiOSWindow();
~ofAppiOSWindow();

static void loop();
static bool doesLoop(){ return true; }
Expand All @@ -147,7 +182,7 @@ class ofAppiOSWindow : public ofAppBaseGLESWindow {
void setup(const ofWindowSettings & _settings);
void setup(const ofGLESWindowSettings & _settings);
void setup(const ofiOSWindowSettings & _settings);
void setup();
void setup();

void run(ofBaseApp * appPtr);
OF_DEPRECATED_MSG("Use setup(const ofiOSWindowSettings & settings); instead.", virtual void setupOpenGL(int w, int h, ofWindowMode screenMode) );
Expand All @@ -157,19 +192,19 @@ class ofAppiOSWindow : public ofAppBaseGLESWindow {

void close();

virtual void hideCursor();
virtual void showCursor();
virtual void hideCursor();
virtual void showCursor();

virtual void setWindowPosition(int x, int y);
virtual void setWindowShape(int w, int h);
virtual glm::vec2 getWindowPosition();
virtual glm::vec2 getWindowSize();
virtual glm::vec2 getScreenSize();
virtual void setWindowPosition(int x, int y);
virtual void setWindowShape(int w, int h);
virtual glm::vec2 getWindowPosition();
virtual glm::vec2 getWindowSize();
virtual glm::vec2 getScreenSize();

#if TARGET_OS_IOS || (TARGET_OS_IPHONE && !TARGET_OS_TV)
virtual void setOrientation(ofOrientation orientation);
virtual ofOrientation getOrientation();
virtual void setOrientation(ofOrientation orientation);
virtual ofOrientation getOrientation();
virtual bool doesHWOrientation();
//-------------------------------------------- ios config.
bool enableHardwareOrientation();
Expand All @@ -178,27 +213,27 @@ class ofAppiOSWindow : public ofAppBaseGLESWindow {
bool enableOrientationAnimation();
bool disableOrientationAnimation();
#endif
virtual int getWidth();
virtual int getHeight();
virtual int getWidth();
virtual int getHeight();

ofiOSWindowSettings & getSettings();
ofCoreEvents & events();
std::shared_ptr<ofBaseRenderer> & renderer();
virtual void setWindowTitle(std::string title);
virtual ofWindowMode getWindowMode();
virtual void setFullscreen(bool fullscreen);
virtual void toggleFullscreen();
virtual void enableSetupScreen();
virtual void disableSetupScreen();
virtual void setWindowTitle(std::string title);
virtual ofWindowMode getWindowMode();
virtual void setFullscreen(bool fullscreen);
virtual void toggleFullscreen();
virtual void enableSetupScreen();
virtual void disableSetupScreen();
virtual bool isSetupScreenEnabled();

virtual void setVerticalSync(bool enabled);
bool isProgrammableRenderer();
ofxiOSRendererType getGLESVersion();
OF_DEPRECATED_MSG("Use ofiOSWindowSettings to setup programmable renderer by selecting glesVerison to >=2", bool enableRendererES2());
Expand All @@ -221,14 +256,21 @@ class ofAppiOSWindow : public ofAppBaseGLESWindow {
bool isAntiAliasingEnabled();
int getAntiAliasingSampleCount();

void enableMultiTouch(bool isOn);
bool isMultiTouch();
ofxiOSWindowControllerType getWindowControllerType();
ofxiOSRendererColorFormat getRendererColorType();
ofxiOSRendererDepthFormat getRendererDepthType();
ofxiOSRendererStencilFormat getRendererStencilType();

protected:

ofCoreEvents coreEvents;
std::shared_ptr<ofBaseRenderer> currentRenderer;
ofiOSWindowSettings settings;

ofOrientation orientation;
ofOrientation orientation;
bool bRetinaSupportedOnDevice;
bool bRetinaSupportedOnDeviceChecked;

Expand Down
78 changes: 64 additions & 14 deletions addons/ofxiOS/src/app/ofAppiOSWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "ofxtvOSViewController.h"
const std::string appDelegateName = "ofxtvOSAppDelegate";
#endif
#include "ofxiOSGLKView.h"
#include "ofxiOSEAGLView.h"

//----------------------------------------------------------------------------------- instance.
Expand Down Expand Up @@ -165,15 +166,24 @@
}

glm::vec2 ofAppiOSWindow::getWindowPosition() {
return *[[ofxiOSEAGLView getInstance] getWindowPosition];
if(settings.windowControllerType == METAL_KIT || settings.windowControllerType == GL_KIT)
return *[[ofxiOSGLKView getInstance] getWindowPosition];
else
return *[[ofxiOSEAGLView getInstance] getWindowPosition];
}

glm::vec2 ofAppiOSWindow::getWindowSize() {
return *[[ofxiOSEAGLView getInstance] getWindowSize];
if(settings.windowControllerType == METAL_KIT || settings.windowControllerType == GL_KIT)
return *[[ofxiOSGLKView getInstance] getWindowSize];
else
return *[[ofxiOSEAGLView getInstance] getWindowSize];
}

glm::vec2 ofAppiOSWindow::getScreenSize() {
return *[[ofxiOSEAGLView getInstance] getScreenSize];
if(settings.windowControllerType == METAL_KIT || settings.windowControllerType == GL_KIT)
return *[[ofxiOSGLKView getInstance] getScreenSize];
else
return *[[ofxiOSEAGLView getInstance] getScreenSize];
}

int ofAppiOSWindow::getWidth(){
Expand Down Expand Up @@ -233,17 +243,21 @@
// otherwise calling glViewController will cause a crash.
return;
}
ofxiOSViewController * glViewController = ((ofxiOSAppDelegate *)appDelegate).glViewController;
ofxiOSEAGLView * glView = glViewController.glView;

if(settings.enableHardwareOrientation == true) {
[glViewController rotateToInterfaceOrientation:interfaceOrientation animated:settings.enableHardwareOrientationAnimation];
} else {
[[UIApplication sharedApplication] setStatusBarOrientation:interfaceOrientation animated:settings.enableHardwareOrientationAnimation];
if(bResized == true) {
[glView layoutSubviews]; // calling layoutSubviews so window resize notification is fired.
}
}
UIViewController * uiViewController = ((ofxiOSAppDelegate *)appDelegate).uiViewController;
if([uiViewController isKindOfClass:[ofxiOSViewController class]] == YES) {
ofxiOSViewController * glViewController = (ofxiOSViewController*)uiViewController;
if(glViewController) {
ofxiOSEAGLView * glView = glViewController.glView;
if(settings.enableHardwareOrientation == true) {
[glViewController rotateToInterfaceOrientation:interfaceOrientation animated:settings.enableHardwareOrientationAnimation];
} else {
[[UIApplication sharedApplication] setStatusBarOrientation:interfaceOrientation animated:settings.enableHardwareOrientationAnimation];
if(bResized == true) {
[glView layoutSubviews]; // calling layoutSubviews so window resize notification is fired.
}
}
}
}
#endif
}

Expand Down Expand Up @@ -394,10 +408,12 @@

//----------------------------------------------------------------------------------- depth buffer.
bool ofAppiOSWindow::enableDepthBuffer() {
settings.depthType = ofxiOSRendererDepthFormat::DEPTH_24;
return (settings.enableDepth = true);
}

bool ofAppiOSWindow::disableDepthBuffer() {
settings.depthType = ofxiOSRendererDepthFormat::DEPTH_NONE;
return (settings.enableDepth = false);
}

Expand All @@ -411,6 +427,24 @@
return (settings.enableAntiAliasing = true);
}

void ofAppiOSWindow::enableMultiTouch(bool isOn) {
settings.enableMultiTouch = isOn;
#if TARGET_OS_IOS || (TARGET_OS_IPHONE && !TARGET_OS_TV)
if(settings.windowControllerType == METAL_KIT || settings.windowControllerType == GL_KIT) {
if([ofxiOSGLKView getInstance]) {
[[ofxiOSGLKView getInstance] setMultipleTouchEnabled:isOn];
}
} else {
if([ofxiOSEAGLView getInstance])
[[ofxiOSEAGLView getInstance] setMultipleTouchEnabled:isOn];
}
#endif
}

bool ofAppiOSWindow::isMultiTouch() {
return settings.enableMultiTouch;
}

bool ofAppiOSWindow::disableAntiAliasing() {
return (settings.enableAntiAliasing = false);
}
Expand All @@ -423,6 +457,22 @@
return settings.numOfAntiAliasingSamples;
}

ofxiOSWindowControllerType ofAppiOSWindow::getWindowControllerType() {
return settings.windowControllerType;
}

ofxiOSRendererColorFormat ofAppiOSWindow::getRendererColorType() {
return settings.colorType;
}

ofxiOSRendererDepthFormat ofAppiOSWindow::getRendererDepthType() {
return settings.depthType;
}

ofxiOSRendererStencilFormat ofAppiOSWindow::getRendererStencilType() {
return settings.stencilType;
}

//-----------------------------------------------------------------------------------
ofCoreEvents & ofAppiOSWindow::events(){
return coreEvents;
Expand Down
4 changes: 3 additions & 1 deletion addons/ofxiOS/src/core/ofxiOSAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@
#import <UIKit/UIKit.h>

@class ofxiOSViewController;
@class ofxiOSGLKViewController;
//@class ofxiOSMTKViewController;

@interface ofxiOSAppDelegate : NSObject <UIApplicationDelegate> {
NSInteger currentScreenIndex;
}

@property (nonatomic, retain) UIWindow * window;
@property (nonatomic, retain) UIWindow * externalWindow;
@property (nonatomic, retain) ofxiOSViewController * glViewController;
@property (nonatomic, retain) UIViewController * uiViewController;
@property (readonly, assign) NSInteger currentScreenIndex;

- (BOOL)application:(UIApplication*)application
Expand Down
Loading