ios stuff

This commit is contained in:
vladislav.khorev committed 2013-02-06 20:38:11 +00:00
1 parent 6c05bac1ac
commit c96eab18dd
12 files changed
+39 -300

No files matched your search

+2 -6
View File
@@ -6,12 +6,8 @@
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <GLKit/GLKit.h>
#import "include/Utils/IosApi/ObjC/GLKViewTemplate.h"
@interface CustomGLKView : GLKView
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
@interface CustomGLKView : GLKViewTemplate
@end
-68
View File
@@ -1,68 +0,0 @@
//
// CustomGLKView.m
// doublehitballs
//
// Created by vvv ооо on 15.07.12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "CustomGLKView.h"
#import "ios_api.h"
bool touchMoved = false;
CGPoint prev_loc;
@implementation CustomGLKView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint location = [[[touches allObjects] objectAtIndex:0] locationInView:self];
prev_loc = location;
touchMoved = false;
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(prev_loc.x - location.x) > 10 || abs(prev_loc.y - location.y) > 10)
{
touchMoved = true;
}
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)
{
AppOnTapUp(location.x, self.bounds.size.height - location.y);
}
}
@end
+4 -3
View File
@@ -6,9 +6,10 @@
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <GLKit/GLKit.h>
@interface ViewController : GLKViewController
#import "include/Utils/IosApi/ObjC/ViewControllerTemplate.h"
@interface ViewController : ViewControllerTemplate
@end
-113
View File
@@ -1,113 +0,0 @@
//
// ViewController.m
// doublehitballs
//
// Created by vvv ооо on 13.07.12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "ViewController.h"
#import "ios_api.h"
extern GLKView* defaultView; //Find this in IosApi.h/mm in Engine
@interface ViewController () {
}
@property (strong, nonatomic) EAGLContext *context;
@property (strong, nonatomic) GLKBaseEffect *effect;
- (void)setupGL;
- (void)tearDownGL;
@end
@implementation ViewController
@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 = (GLKView *)self.view;
[self setupGL];
}
- (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.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
/*
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}*/
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
- (void)setupGL
{
[EAGLContext setCurrentContext:self.context];
AppInit();
GLKView *view = (GLKView *)self.view;
}
- (void)tearDownGL
{
[EAGLContext setCurrentContext:self.context];
AppDeinit();
}
#pragma mark - GLKView and GLKViewController delegate methods
- (void)update
{
AppUpdate(self.timeSinceLastUpdate * 1000);
}
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
AppDraw();
}
@end
+2 -49
View File
@@ -1,55 +1,8 @@
#include "include/Engine.h"
#include "main_code.h"
TAndroidApplication* App;
extern "C" void AppInit()
void CustomAppInit()
{
CreateEngine();
App = new TAndroidApplication;
App->OuterInit(480, 320, 480, 320);
}
extern "C" void AppDeinit()
{
App->OuterDeinit();
delete App;
DestroyEngine();
}
extern "C" void AppUpdate(int dt)
{
App->OuterUpdate(dt);
}
extern "C" void AppDraw()
{
App->OuterDraw();
}
extern "C" void AppOnTapDown(int posx, int posy)
{
App->OuterOnTapDown(vec2(posx, posy));
}
extern "C" void AppOnTapUp(int posx, int posy)
{
App->OuterOnTapUp(vec2(posx, posy));
}
extern "C" void AppOnTapUpAfterScroll(int posx, int posy)
{
App->OuterOnTapUpAfterShift(vec2(posx, posy));
}
extern "C" void AppOnScroll(int shiftx, int shifty)
{
App->OuterOnMove(vec2(shiftx, shifty));
AppInit<TAndroidApplication>(480, 320);
}
+1 -15
View File
@@ -1,15 +1 @@
//
// Header.h
// doublehitballs
//
// Created by vvv ооо on 15.07.12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
void AppInit();
void AppDeinit();
void AppUpdate(int dt);
void AppDraw();
void AppOnTapDown(int posx, int posy);
void AppOnTapUp(int posx, int posy);
void AppOnScroll(int shiftx, int shifty);
void CustomAppInit();