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
4 changes: 3 additions & 1 deletion addons/ofxiOS/src/core/ofxiOSGLKView.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ class ofAppiOSWindow;

+ (ofxiOSGLKView *) getInstance;

- (id)initWithFrame:(CGRect)frame
andApp:(ofxiOSApp *)app;
- (id)initWithFrame:(CGRect)frame
andApp:(ofxiOSApp *)app
sharegroup:(EAGLSharegroup *)sharegroup;
- (void)setup;
- (void)update;
- (void)draw;

- (void)setMSAA:(bool)on;
- (void)updateDimensions;
- (void)destroy;
- (CGPoint)orientateTouchPoint:(CGPoint)touchPoint;
Expand Down
12 changes: 12 additions & 0 deletions addons/ofxiOS/src/core/ofxiOSGLKView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ + (ofxiOSGLKView *) getInstance {
return _instanceRef;
}

- (id)initWithFrame:(CGRect)frame andApp:(ofxiOSApp *)appPtr {
return [self initWithFrame:frame andApp:appPtr sharegroup:nil];
}

- (id)initWithFrame:(CGRect)frame andApp:(ofxiOSApp *)appPtr sharegroup:(EAGLSharegroup *)sharegroup{

window = dynamic_pointer_cast<ofAppiOSWindow>(ofGetMainLoop()->getCurrentWindow());
Expand Down Expand Up @@ -164,6 +168,14 @@ - (void)updateDimensions {
*screenSize = glm::vec2(currentScreen.bounds.size.width * scaleFactor, currentScreen.bounds.size.height * scaleFactor);
}

- (void) setMSAA:(bool)on
{
if(on)
self.drawableMultisample = GLKViewDrawableMultisample4X;
else
self.drawableMultisample = GLKViewDrawableMultisampleNone;
}

- (void)notifyResized {
// blank this.
// we want to notifyResized at the end of layoutSubviews.
Expand Down
2 changes: 2 additions & 0 deletions addons/ofxiOS/src/core/ofxiOSGLKViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ofxiOSApp;

@property (nonatomic, retain) ofxiOSGLKView * glView;

- (id)initWithFrame:(CGRect)frame app:(ofxiOSApp *)app;
- (id)initWithFrame:(CGRect)frame app:(ofxiOSApp *)app sharegroup:(EAGLSharegroup *)sharegroup;

- (UIInterfaceOrientation)currentInterfaceOrientation;
Expand All @@ -31,6 +32,7 @@ class ofxiOSApp;
animated:(BOOL)animated;
- (BOOL)isReadyToRotate;
- (void)setPreferredFPS:(int)fps;
- (void)setMSAA:(bool)value;
- (EAGLSharegroup *)getSharegroup;

@end
Expand Down
12 changes: 11 additions & 1 deletion addons/ofxiOS/src/core/ofxiOSGLKViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#import "ofxiOSExtras.h"
#include "ofAppiOSWindow.h"

@interface ofxiOSGLKViewController() <EAGLViewDelegate, GLKViewControllerDelegate> {
@interface ofxiOSGLKViewController() <EAGLKViewDelegate, GLKViewControllerDelegate> {
UIInterfaceOrientation currentInterfaceOrientation;
UIInterfaceOrientation pendingInterfaceOrientation;
BOOL bReadyToRotate;
Expand All @@ -27,6 +27,10 @@ @implementation ofxiOSGLKViewController

@synthesize glView;

- (id)initWithFrame:(CGRect)frame app:(ofxiOSApp *)app {
return [self initWithFrame:frame app:app sharegroup:nil];
}

- (id)initWithFrame:(CGRect)frame app:(ofxiOSApp *)app sharegroup:(EAGLSharegroup *)sharegroup{
currentInterfaceOrientation = pendingInterfaceOrientation = UIInterfaceOrientationPortrait;
if((self = [super init])) {
Expand Down Expand Up @@ -458,6 +462,12 @@ - (void)setPreferredFPS:(int)fps {
}
}

- (void)setMSAA:(bool)value {
if(self.glView != nil) {
[self.glView setMSAA:value];
}
}

@end

#endif
3 changes: 2 additions & 1 deletion addons/ofxiOS/src/gl/EAGLKView.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#import <GLKit/GLKit.h>
#import "ESRenderer.h"

@protocol EAGLViewDelegate <NSObject>
@protocol EAGLKViewDelegate <NSObject>
@optional
- (void)glViewAnimationStarted;
- (void)glViewAnimationStopped;
Expand Down Expand Up @@ -61,6 +61,7 @@ andPreferedRenderer:(ESRendererVersion)rendererVersion
#ifdef __IPHONE_9_1
- (void)touchesEstimatedPropertiesUpdated:(NSSet<UITouch *> *)touches NS_AVAILABLE_IOS(9_1);
#endif
- (void)setMSAA:(bool)on;
- (void)notifyAnimationStarted;
- (void)notifyAnimationStopped;
- (void)notifyDraw;
Expand Down
8 changes: 8 additions & 0 deletions addons/ofxiOS/src/gl/EAGLKView.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ - (void)updateScaleFactor {
}
}

- (void) setMSAA:(bool)on
{
if(on)
self.drawableMultisample = GLKViewDrawableMultisample4X;
else
self.drawableMultisample = GLKViewDrawableMultisampleNone;
}

//------------------------------------------------------------------- notify.
- (void) notifyAnimationStarted {
if([self.delegate respondsToSelector:@selector(glViewAnimationStarted)]) {
Expand Down
2 changes: 1 addition & 1 deletion addons/ofxiOS/src/tvOS/ofxtvOSGLKViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "ofxtvOSGLKViewController.h"
#include "ofxiOSGLKView.h"

@interface ofxtvOSGLKViewController() <EAGLViewDelegate, GLKViewControllerDelegate> {
@interface ofxtvOSGLKViewController() <EAGLKViewDelegate, GLKViewControllerDelegate> {
UITapGestureRecognizer *tapRecognizer;
}
@end
Expand Down
5 changes: 5 additions & 0 deletions addons/ofxiOS/src/utils/ofxiOSExtras.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ class ofAppiOSWindow;
#if TARGET_OS_IOS || (TARGET_OS_IPHONE && !TARGET_OS_TV)
@class ofxiOSAppDelegate;
@class ofxiOSViewController;
@class ofxiOSGLKViewController;
#elif TARGET_OS_TV
@class ofxtvOSAppDelegate;
@class ofxtvOSViewController;
@class ofxtvOSGLKViewController;
#endif
@class ofxiOSEAGLView;
@class ofxiOSGLKView;

// this is the new way for getting device info.
// we can add other parameters later.
Expand Down Expand Up @@ -95,6 +98,8 @@ UIWindow * ofxiOSGetUIWindow();
// return openglview
ofxiOSEAGLView * ofxiOSGetGLView();

ofxiOSGLKView * ofxiOSGetGLKView();

// return opengl parent view
UIView * ofxiOSGetGLParentView();

Expand Down
6 changes: 6 additions & 0 deletions addons/ofxiOS/src/utils/ofxiOSExtras.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "ofxtvOSViewController.h"
#endif
#include "ofxiOSEAGLView.h"
#include "ofxiOSGLKView.h"
#include "ofAppiOSWindow.h"
#include "ofAppRunner.h"
#include "ofImage.h"
Expand Down Expand Up @@ -144,6 +145,11 @@ ofxiOSDeviceInfo ofxiOSGetDeviceInfo(){
return [ofxiOSEAGLView getInstance];
}

//--------------------------------------------------------------
ofxiOSGLKView * ofxiOSGetGLKView() {
return [ofxiOSGLKView getInstance];
}

//--------------------------------------------------------------
UIView * ofxiOSGetGLParentView() {
return ofxiOSGetGLView().superview;
Expand Down
23 changes: 23 additions & 0 deletions examples/ios/GLKit/src/main.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "ofApp.h"

int main() {

// here are the most commonly used iOS window settings.
//------------------------------------------------------
ofiOSWindowSettings settings;
settings.enableRetina = true; // enables retina resolution if the device supports it.
settings.enableDepth = false; // enables depth buffer for 3d drawing.
settings.enableAntiAliasing = false; // enables anti-aliasing which smooths out graphics on the screen.
settings.numOfAntiAliasingSamples = 0; // number of samples used for anti-aliasing.
settings.enableHardwareOrientation = false; // enables native view orientation.
settings.enableHardwareOrientationAnimation = false; // enables native orientation changes to be animated.
settings.glesVersion = OFXIOS_RENDERER_ES2; // type of renderer to use, ES1, ES2, ES3
settings.windowControllerType = ofxiOSWindowControllerType::GL_KIT; // Window Controller Type
settings.colorType = ofxiOSRendererColorFormat::RGBA8888; // color format used default RGBA8888
settings.depthType = ofxiOSRendererDepthFormat::DEPTH_NONE; // depth format (16/24) if depth enabled
settings.stencilType = ofxiOSRendererStencilFormat::STENCIL_NONE; // stencil mode
settings.windowMode = OF_FULLSCREEN;
ofCreateWindow(settings);

return ofRunApp(new ofApp);
}
26 changes: 26 additions & 0 deletions examples/ios/GLKit/src/ofApp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include "ofxiOS.h"

class ofApp : public ofxiOSApp {

public:
void setup();
void update();
void draw();
void exit();

void touchDown(ofTouchEventArgs & touch);
void touchMoved(ofTouchEventArgs & touch);
void touchUp(ofTouchEventArgs & touch);
void touchDoubleTap(ofTouchEventArgs & touch);
void touchCancelled(ofTouchEventArgs & touch);

void lostFocus();
void gotFocus();
void gotMemoryWarning();
void deviceOrientationChanged(int newOrientation);

};


66 changes: 66 additions & 0 deletions examples/ios/GLKit/src/ofApp.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){

}

//--------------------------------------------------------------
void ofApp::update(){

}

//--------------------------------------------------------------
void ofApp::draw(){

}

//--------------------------------------------------------------
void ofApp::exit(){

}

//--------------------------------------------------------------
void ofApp::touchDown(ofTouchEventArgs & touch){

}

//--------------------------------------------------------------
void ofApp::touchMoved(ofTouchEventArgs & touch){

}

//--------------------------------------------------------------
void ofApp::touchUp(ofTouchEventArgs & touch){

}

//--------------------------------------------------------------
void ofApp::touchDoubleTap(ofTouchEventArgs & touch){

}

//--------------------------------------------------------------
void ofApp::touchCancelled(ofTouchEventArgs & touch){

}

//--------------------------------------------------------------
void ofApp::lostFocus(){

}

//--------------------------------------------------------------
void ofApp::gotFocus(){

}

//--------------------------------------------------------------
void ofApp::gotMemoryWarning(){

}

//--------------------------------------------------------------
void ofApp::deviceOrientationChanged(int newOrientation){

}
Empty file.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#import "ofxiOSGLKViewController.h"

@interface CircleAppViewController : ofxiOSGLKViewController

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// CustomAppViewController.m
// Created by lukasz karluk on 8/02/12.
//

#import "CircleAppViewController.h"
#import "ofxiOSExtras.h"
#import "ofAppiOSWindow.h"

@implementation CircleAppViewController

- (id) initWithFrame:(CGRect)frame app:(ofxiOSApp *)app {

ofxiOSGetOFWindow()->setOrientation( OF_ORIENTATION_DEFAULT ); //-- default portait orientation.

return self = [super initWithFrame:frame app:app sharegroup:nil];
}

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return NO;
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#import "ofxiOSGLKViewController.h"

@interface ImageAppViewController : ofxiOSGLKViewController

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#import "ImageAppViewController.h"
#import "ofxiOSExtras.h"
#import "ofAppiOSWindow.h"

@implementation ImageAppViewController

- (id) initWithFrame:(CGRect)frame app:(ofxiOSApp *)app {

ofxiOSGetOFWindow()->setOrientation( OF_ORIENTATION_DEFAULT ); //-- default portait orientation.

return self = [super initWithFrame:frame app:app sharegroup:nil];
}

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return NO;
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#import "ofxiOSGLKViewController.h"

@interface SquareAppViewController : ofxiOSGLKViewController

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// CustomAppViewController.m
// Created by lukasz karluk on 8/02/12.
//

#import "SquareAppViewController.h"
#import "ofxiOSExtras.h"
#import "ofAppiOSWindow.h"

@implementation SquareAppViewController

- (id) initWithFrame:(CGRect)frame app:(ofxiOSApp *)app {

ofxiOSGetOFWindow()->setOrientation( OF_ORIENTATION_DEFAULT ); //-- default portait orientation.

return self = [super initWithFrame:frame app:app sharegroup:nil];
}

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return NO;
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#import "ofxiOSGLKViewController.h"

@interface TriangleAppViewController : ofxiOSGLKViewController

@end
Loading