Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Metal ANGLE Prototype #6981

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a37827b
update window and utility
2bbb Jan 23, 2022
058cec0
update video player
2bbb Jan 23, 2022
f21e0e3
update video grabber and player
2bbb Jan 23, 2022
351f908
add ARC flag on xcconfig
2bbb Jan 23, 2022
fbd6e46
add flag on make setting
2bbb Jan 23, 2022
5dea97d
add flag enabling ARC on iOS env
2bbb Jan 23, 2022
d9709fb
update to ARC code
2bbb Jan 23, 2022
c081a7f
comment out unneeded substitute
2bbb Jan 23, 2022
88de148
update to ARC, strict check selector
2bbb Jan 23, 2022
bbcb7ca
update to ARC (simple updates)
2bbb Jan 23, 2022
3c529f4
update to ARC, change: hold delegate because MKMapView doesn't hold it.
2bbb Jan 23, 2022
9bff927
update to ARC (simple updates)
2bbb Jan 23, 2022
bc6f39a
update to ARC
2bbb Jan 23, 2022
020ecd4
update to ARC (tvOS)
2bbb Jan 23, 2022
8dd7a3a
update to remove flag disable ARC on pbxproj
2bbb Jan 23, 2022
ef4befc
fix include guard
2bbb Jan 23, 2022
0908c4b
resolve confilict to current master
2bbb Mar 11, 2022
cbef3f2
Merge branch 'master' into obj-c-arc
2bbb Mar 11, 2022
96f11b8
remove ARC feature test from implementation, add it to env conditiona…
2bbb Mar 17, 2022
b77fd3d
remove ARC feature test from tvos implementation files
2bbb Mar 17, 2022
da9a875
replace id type to instancetype on initXXX methods
2bbb Mar 17, 2022
962432e
add TODO about delegates and protocols
2bbb Mar 17, 2022
9c769a9
Metal
danoli3 May 11, 2022
3c4a39b
iOS Metal Renderer working
danoli3 May 13, 2022
3a93ef4
Metal Developments
danoli3 Jun 2, 2022
6db550f
Temp Fixes
danoli3 Jun 2, 2022
92bb06e
Further Metal Developments for iOS oF
danoli3 Nov 15, 2022
ce368f7
iOS Fix Video Player
danoli3 Jul 12, 2023
29aa4cd
iOS Extras Fixes
danoli3 Oct 28, 2024
9f583a2
ofxiOSVideoPlayer Fix
danoli3 Oct 29, 2024
81a2dea
Merge branch 'ios_fixes'
danoli3 Nov 5, 2024
28b2325
Merge commit '92bb06eeccee8bc5a09198f3706d62c5e4f4272c'
danoli3 Nov 5, 2024
201d5dc
Merge commit 'e084543a4be8e062cce7bf755f2264334248b22f' into metal
danoli3 Nov 14, 2024
a70718b
Merge Fixes
danoli3 Nov 14, 2024
e604e75
Metal ANGLE
danoli3 Jan 8, 2025
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
249 changes: 124 additions & 125 deletions addons/ofxiOS/src/app/ofAppiOSWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,139 +30,138 @@
* ***********************************************************************/

#pragma once
#include "ofxiOSConstants.h"
#if defined(TARGET_OF_IOS)
#include <TargetConditionals.h>
#include "ofAppBaseWindow.h"
#include "ofxiOSConstants.h"
#include "ofEvents.h"

class ofiOSWindowSettings: public ofGLESWindowSettings{
public:
ofiOSWindowSettings()
:enableRetina(true)
,retinaScale(0)
,enableDepth(false)
,enableAntiAliasing(false)
,numOfAntiAliasingSamples(0)
,enableHardwareOrientation(false)
,enableHardwareOrientationAnimation(false)
,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 = 2;
}

ofiOSWindowSettings(const ofWindowSettings & settings)
:ofGLESWindowSettings(settings)
,enableRetina(true)
,retinaScale(0)
,enableDepth(false)
,enableAntiAliasing(false)
,numOfAntiAliasingSamples(0)
,enableHardwareOrientation(false)
,enableHardwareOrientationAnimation(false)
,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 = 2;
}
const ofiOSWindowSettings * iosSettings = dynamic_cast<const ofiOSWindowSettings*>(&settings);
if(iosSettings){
enableRetina = iosSettings->enableRetina;
retinaScale = iosSettings->retinaScale;
enableDepth = iosSettings->enableDepth;
enableAntiAliasing = iosSettings->enableAntiAliasing;
numOfAntiAliasingSamples = iosSettings->numOfAntiAliasingSamples;
enableHardwareOrientation = iosSettings->enableHardwareOrientation;
enableHardwareOrientationAnimation = iosSettings->enableHardwareOrientationAnimation;
enableSetupScreen = iosSettings->enableSetupScreen;
setupOrientation = iosSettings->setupOrientation;
windowControllerType = iosSettings->windowControllerType;
colorType = iosSettings->colorType;
depthType = iosSettings->depthType;
stencilType = iosSettings->stencilType;
enableMultiTouch = iosSettings->enableMultiTouch;
} else {
enableRetina = true;
retinaScale = 0;
enableDepth = false;
enableAntiAliasing = false;
numOfAntiAliasingSamples = 0;
enableHardwareOrientation = false;
enableHardwareOrientationAnimation = false;
enableSetupScreen = true;
setupOrientation = OF_ORIENTATION_DEFAULT;
colorType = ofxiOSRendererColorFormat::RGBA8888;
depthType = ofxiOSRendererDepthFormat::DEPTH_NONE;
stencilType = ofxiOSRendererStencilFormat::STENCIL_NONE;
enableMultiTouch = false;
}
}
ofiOSWindowSettings()
:enableRetina(true)
,retinaScale(0)
,enableDepth(false)
,enableAntiAliasing(false)
,numOfAntiAliasingSamples(0)
,enableHardwareOrientation(false)
,enableHardwareOrientationAnimation(false)
,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 = 2;
}

ofiOSWindowSettings(const ofWindowSettings & settings)
:ofGLESWindowSettings(settings)
,enableRetina(true)
,retinaScale(0)
,enableDepth(false)
,enableAntiAliasing(false)
,numOfAntiAliasingSamples(0)
,enableHardwareOrientation(false)
,enableHardwareOrientationAnimation(false)
,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 = 2;
}
const ofiOSWindowSettings * iosSettings = dynamic_cast<const ofiOSWindowSettings*>(&settings);
if(iosSettings){
enableRetina = iosSettings->enableRetina;
retinaScale = iosSettings->retinaScale;
enableDepth = iosSettings->enableDepth;
enableAntiAliasing = iosSettings->enableAntiAliasing;
numOfAntiAliasingSamples = iosSettings->numOfAntiAliasingSamples;
enableHardwareOrientation = iosSettings->enableHardwareOrientation;
enableHardwareOrientationAnimation = iosSettings->enableHardwareOrientationAnimation;
enableSetupScreen = iosSettings->enableSetupScreen;
setupOrientation = iosSettings->setupOrientation;
windowControllerType = iosSettings->windowControllerType;
colorType = iosSettings->colorType;
depthType = iosSettings->depthType;
stencilType = iosSettings->stencilType;
enableMultiTouch = iosSettings->enableMultiTouch;
} else {
enableRetina = true;
retinaScale = 0;
enableDepth = false;
enableAntiAliasing = false;
numOfAntiAliasingSamples = 0;
enableHardwareOrientation = false;
enableHardwareOrientationAnimation = false;
enableSetupScreen = true;
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(true)
,retinaScale(0)
,enableDepth(false)
,enableAntiAliasing(false)
,numOfAntiAliasingSamples(0)
,enableHardwareOrientation(false)
,enableHardwareOrientationAnimation(false)
,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;
retinaScale = iosSettings->retinaScale;
enableDepth = iosSettings->enableDepth;
enableAntiAliasing = iosSettings->enableAntiAliasing;
numOfAntiAliasingSamples = iosSettings->numOfAntiAliasingSamples;
enableHardwareOrientation = iosSettings->enableHardwareOrientation;
enableHardwareOrientationAnimation = iosSettings->enableHardwareOrientationAnimation;
enableSetupScreen = iosSettings->enableSetupScreen;
setupOrientation = iosSettings->setupOrientation;
windowControllerType = iosSettings->windowControllerType;
colorType = iosSettings->colorType;
depthType = iosSettings->depthType;
stencilType = iosSettings->stencilType;
enableMultiTouch = iosSettings->enableMultiTouch;
}
}
ofiOSWindowSettings(const ofGLESWindowSettings & settings)
:ofGLESWindowSettings(settings)
,enableRetina(true)
,retinaScale(0)
,enableDepth(false)
,enableAntiAliasing(false)
,numOfAntiAliasingSamples(0)
,enableHardwareOrientation(false)
,enableHardwareOrientationAnimation(false)
,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;
retinaScale = iosSettings->retinaScale;
enableDepth = iosSettings->enableDepth;
enableAntiAliasing = iosSettings->enableAntiAliasing;
numOfAntiAliasingSamples = iosSettings->numOfAntiAliasingSamples;
enableHardwareOrientation = iosSettings->enableHardwareOrientation;
enableHardwareOrientationAnimation = iosSettings->enableHardwareOrientationAnimation;
enableSetupScreen = iosSettings->enableSetupScreen;
setupOrientation = iosSettings->setupOrientation;
windowControllerType = iosSettings->windowControllerType;
colorType = iosSettings->colorType;
depthType = iosSettings->depthType;
stencilType = iosSettings->stencilType;
enableMultiTouch = iosSettings->enableMultiTouch;
}
}

virtual ~ofiOSWindowSettings(){};
bool enableRetina;
float retinaScale;
bool enableDepth;
bool enableAntiAliasing;
int numOfAntiAliasingSamples;
bool enableHardwareOrientation;
bool enableHardwareOrientationAnimation;
bool enableSetupScreen;
bool enableMultiTouch;
ofxiOSWindowControllerType windowControllerType;
ofxiOSRendererColorFormat colorType;
ofxiOSRendererDepthFormat depthType;
ofxiOSRendererStencilFormat stencilType;
ofOrientation setupOrientation;
virtual ~ofiOSWindowSettings(){};
bool enableRetina;
float retinaScale;
bool enableDepth;
bool enableAntiAliasing;
int numOfAntiAliasingSamples;
bool enableHardwareOrientation;
bool enableHardwareOrientationAnimation;
bool enableSetupScreen;
bool enableMultiTouch;
ofxiOSWindowControllerType windowControllerType;
ofxiOSRendererColorFormat colorType;
ofxiOSRendererDepthFormat depthType;
ofxiOSRendererStencilFormat stencilType;
ofOrientation setupOrientation;
};


Expand Down Expand Up @@ -286,5 +285,5 @@ class ofAppiOSWindow : public ofAppBaseGLESWindow {
[[deprecated("use ofAppiOSWindow")]]
typedef ofAppiOSWindow ofAppiPhoneWindow;

#endif


21 changes: 16 additions & 5 deletions addons/ofxiOS/src/app/ofAppiOSWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
const std::string appDelegateName = "ofxtvOSAppDelegate";
#endif
#include "ofxiOSGLKView.h"
#include "MGLKView.h"
#include "ofxiOSEAGLView.h"

//----------------------------------------------------------------------------------- instance.
Expand Down Expand Up @@ -137,7 +138,7 @@
bAppCreated = true;

@autoreleasepool {
UIApplicationMain(0, nil, nil, [NSString stringWithUTF8String:appDelegateClassName.c_str()]);
UIApplicationMain(0, 0, nil, [NSString stringWithUTF8String:appDelegateClassName.c_str()]);
}
}

Expand Down Expand Up @@ -168,21 +169,27 @@
}

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

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

glm::vec2 ofAppiOSWindow::getScreenSize() {
if(settings.windowControllerType == METAL_KIT || settings.windowControllerType == GL_KIT)
if(settings.windowControllerType == METAL_KIT) {
return *[[MGLKView getInstance] getScreenSize];
} else if(settings.windowControllerType == GL_KIT)
return *[[ofxiOSGLKView getInstance] getScreenSize];
else
return *[[ofxiOSEAGLView getInstance] getScreenSize];
Expand Down Expand Up @@ -432,7 +439,11 @@
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(settings.windowControllerType == METAL_KIT) {
if([MGLKView getInstance]) {
[[MGLKView getInstance] setMultipleTouchEnabled:isOn];
}
} else if(settings.windowControllerType == GL_KIT) {
if([ofxiOSGLKView getInstance]) {
[[ofxiOSGLKView getInstance] setMultipleTouchEnabled:isOn];
}
Expand Down
2 changes: 1 addition & 1 deletion addons/ofxiOS/src/core/ofxiOSAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

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

@interface ofxiOSAppDelegate : NSObject <UIApplicationDelegate> {
NSInteger currentScreenIndex;
Expand Down
21 changes: 20 additions & 1 deletion addons/ofxiOS/src/core/ofxiOSAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#import "ofxiOSAppDelegate.h"
#import "ofxiOSViewController.h"
#import "ofxiOSGLKViewController.h"

#import "ofxiOSViewController.h"
#import "ofxiOSGLKViewController.h"
#import "ofxiOSMLKViewController.h"
#import "ofxiOSExternalDisplay.h"
#include "ofxiOSExtras.h"
#include "ofxiOSAlerts.h"
Expand Down Expand Up @@ -138,7 +142,15 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application {

switch(ofxiOSGetOFWindow()->getWindowControllerType()) {
case METAL_KIT:
NSLog(@"No MetalKit yet supported for openFrameworks: Falling back to GLKit");
NSLog(@"Metal ANGLE openFrameworks");
// self.uiViewController = (UIViewController *)[[ofxiOSMLKViewController alloc] initWithFrame:frame app:(ofxiOSApp *)ofGetAppPtr()];

// UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
// ofxiOSAppDelegate *del = (ofxiOSAppDelegate *)[UIApplication sharedApplication].delegate;
// MGLKViewController * game = [storyboard instantiateViewControllerWithIdentifier:@"iOSAppMGLKViewController"];
// [del.navigationController pushViewController:game animated:YES];


case GL_KIT:
self.uiViewController = (UIViewController *)[[ofxiOSGLKViewController alloc] initWithFrame:frame app:(ofxiOSApp *)ofGetAppPtr() sharegroup:nil];
break;
Expand Down Expand Up @@ -252,6 +264,13 @@ - (void)receivedRotate:(NSNotification*)notification {
if([controller isReadyToRotate]) {
ofxiOSAlerts.deviceOrientationChanged( deviceOrientation );
}
#if defined(OF_METAL)
} else if([self.uiViewController isKindOfClass:ofxiOSMLKViewController.class]) {
ofxiOSMLKViewController *controller = (ofxiOSMLKViewController *)self.uiViewController;
if([controller isReadyToRotate]) {
ofxiOSAlerts.deviceOrientationChanged( deviceOrientation );
}
#endif /* OF_METAL_KIT */
}
}
}else {
Expand Down
5 changes: 5 additions & 0 deletions addons/ofxiOS/src/core/ofxiOSGLKViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@
#import <UIKit/UIKit.h>
#import <GLKit/GLKit.h>

#if defined(METALKIT)
#import <MetalANGLE/MGLKViewController.h>
#endif

class ofxiOSApp;
@class ofxiOSGLKView;

@interface ofxiOSGLKViewController : GLKViewController


@property (nonatomic, strong) ofxiOSGLKView * glView;

- (instancetype)initWithFrame:(CGRect)frame app:(ofxiOSApp *)app;
Expand Down
Loading
Loading