ios stuff
This commit is contained in:
1 parent
4e695fe902
commit
6ec81a421e
11 files changed
+374
-9
No files matched your search
@@ -116,9 +116,9 @@ void TApplicationAncestor::OuterOnTapUp(vec2 p)
|
||||
InnerOnTapUp(p);
|
||||
}
|
||||
|
||||
void TApplicationAncestor::OuterOnTapUpAfterShift(vec2 p)
|
||||
void TApplicationAncestor::OuterOnTapUpAfterMove(vec2 p)
|
||||
{
|
||||
InnerOnTapUpAfterShift(p);
|
||||
InnerOnTapUpAfterMove(p);
|
||||
}
|
||||
|
||||
void TApplicationAncestor::OuterOnMove(vec2 shift)
|
||||
|
||||
+58
-3
@@ -48,7 +48,62 @@ void DestroyEngine()
|
||||
Console = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TApplication* App = NULL;
|
||||
|
||||
void AppDeinit()
|
||||
{
|
||||
App->OuterDeinit();
|
||||
delete App;
|
||||
App = NULL;
|
||||
DestroyEngine();
|
||||
}
|
||||
|
||||
|
||||
void AppUpdate(int dt)
|
||||
{
|
||||
App->OuterUpdate(dt);
|
||||
}
|
||||
|
||||
|
||||
void AppDraw()
|
||||
{
|
||||
App->OuterDraw();
|
||||
}
|
||||
|
||||
|
||||
void AppOnTapDown(int posx, int posy)
|
||||
{
|
||||
App->OuterOnTapDown(vec2(posx, posy));
|
||||
}
|
||||
|
||||
|
||||
void AppOnTapUp(int posx, int posy)
|
||||
{
|
||||
App->OuterOnTapUp(vec2(posx, posy));
|
||||
}
|
||||
|
||||
|
||||
void AppOnTapUpAfterMove(int posx, int posy)
|
||||
{
|
||||
App->OuterOnTapUpAfterMove(vec2(posx, posy));
|
||||
}
|
||||
|
||||
|
||||
void AppOnScroll(int shiftx, int shifty)
|
||||
{
|
||||
App->OuterOnMove(vec2(shiftx, shifty));
|
||||
}
|
||||
|
||||
|
||||
void AppOnScale(float scale)
|
||||
{
|
||||
App->OnScale(scale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} //namespace SE
|
||||
} //namespace SE
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// CustomGLKView.m
|
||||
// doublehitballs
|
||||
//
|
||||
// Created by vvv ооо on 15.07.12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "include/Utils/IosApi/ObjC/GLKViewTemplate.h"
|
||||
#include "include/Utils/IosApi/IosWrapper.h"
|
||||
|
||||
@implementation GLKViewTemplate
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self)
|
||||
{
|
||||
|
||||
touchMoved = false;
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
|
||||
CGPoint location = [[[touches allObjects] objectAtIndex:0] locationInView:self];
|
||||
|
||||
touchBeganLocation = location;
|
||||
|
||||
touchMoved = false;
|
||||
|
||||
SE::AppOnTapDown(location.x, self.bounds.size.height - location.y);
|
||||
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
CGPoint location = [[[touches allObjects] objectAtIndex:0] locationInView:self];
|
||||
|
||||
CGPoint prevLocation = [[[touches allObjects] objectAtIndex:0] previousLocationInView:self];
|
||||
|
||||
if (abs(touchBeganLocation.x - location.x) > 10 || abs(touchBeganLocation.y - location.y) > 10)
|
||||
{
|
||||
touchMoved = true;
|
||||
}
|
||||
|
||||
SE::AppOnScroll(prevLocation.x - location.x, -(prevLocation.y - location.y));
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
CGPoint location = [[[touches allObjects] objectAtIndex:0] locationInView:self];
|
||||
|
||||
if (touchMoved)
|
||||
{
|
||||
SE::AppOnTapUpAfterMove(location.x, self.bounds.size.height - location.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
SE::AppOnTapUp(location.x, self.bounds.size.height - location.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,119 @@
|
||||
//
|
||||
// ViewController.m
|
||||
// doublehitballs
|
||||
//
|
||||
// Created by vvv ооо on 13.07.12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "include/Utils/IosApi/ObjC/ViewControllerTemplate.h"
|
||||
#include "include/Utils/IosApi/IosWrapper.h"
|
||||
|
||||
|
||||
extern GLKView* defaultView; //Find this in IosApi.mm
|
||||
|
||||
|
||||
@interface ViewControllerTemplate () {
|
||||
}
|
||||
|
||||
@property (strong, nonatomic) EAGLContext *context;
|
||||
@property (strong, nonatomic) GLKBaseEffect *effect;
|
||||
|
||||
- (void)setupGL;
|
||||
- (void)tearDownGL;
|
||||
|
||||
@end
|
||||
|
||||
@implementation ViewControllerTemplate
|
||||
|
||||
@synthesize context = _context;
|
||||
@synthesize effect = _effect;
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||
|
||||
if (!self.context) {
|
||||
NSLog(@"Failed to create ES context");
|
||||
}
|
||||
|
||||
GLKView *view = (GLKView *)self.view;
|
||||
view.context = self.context;
|
||||
view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
|
||||
|
||||
defaultView = view;
|
||||
|
||||
[self setupGL];
|
||||
|
||||
|
||||
|
||||
//Gesture Recognizers
|
||||
|
||||
UIPinchGestureRecognizer *recognizer = [[UIPinchGestureRecognizer alloc]
|
||||
initWithTarget:self action:@selector(respondToPinch:)];
|
||||
|
||||
[self.view addGestureRecognizer:recognizer];
|
||||
}
|
||||
|
||||
- (void)viewDidUnload
|
||||
{
|
||||
[super viewDidUnload];
|
||||
|
||||
[self tearDownGL];
|
||||
|
||||
if ([EAGLContext currentContext] == self.context) {
|
||||
[EAGLContext setCurrentContext:nil];
|
||||
}
|
||||
self.context = nil;
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
// Release any cached data, images, etc. that aren't in use.
|
||||
}
|
||||
|
||||
- (void)setupGL
|
||||
{
|
||||
[EAGLContext setCurrentContext:self.context];
|
||||
|
||||
[self appInitCaller];
|
||||
}
|
||||
|
||||
- (void)tearDownGL
|
||||
{
|
||||
[EAGLContext setCurrentContext:self.context];
|
||||
|
||||
SE::AppDeinit();
|
||||
|
||||
}
|
||||
|
||||
- (void) appInitCaller
|
||||
{
|
||||
}
|
||||
|
||||
- (void)respondToPinch:(UIPinchGestureRecognizer *)gestureRecognizer
|
||||
{
|
||||
SE::AppOnScale(gestureRecognizer.scale);
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - GLKView and GLKViewController delegate methods
|
||||
|
||||
- (void)update
|
||||
{
|
||||
|
||||
SE::AppUpdate(self.timeSinceLastUpdate * 1000);
|
||||
}
|
||||
|
||||
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
|
||||
{
|
||||
|
||||
SE::AppDraw();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user