[DEV] Ios port
This commit is contained in:
parent
628d593326
commit
852543d957
@ -11,6 +11,7 @@
|
||||
|
||||
#import <ewol/context/IOs/OpenglView.h>
|
||||
#import <ewol/context/IOs/AppDelegate.h>
|
||||
#include <ewol/context/IOs/Context.h>
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
@ -24,7 +25,9 @@
|
||||
glView = [[OpenglView alloc] initWithFrame:window.bounds];
|
||||
[window addSubview:glView];
|
||||
[window makeKeyAndVisible];
|
||||
|
||||
// Create interface of ewol here ....
|
||||
NSLog(@"CREATE EWOL interface creation\n");
|
||||
IOs::createInterface();
|
||||
glView.animationInterval = 1.0 / 60.0;
|
||||
[glView startAnimation];
|
||||
}
|
||||
@ -63,6 +66,9 @@
|
||||
- (void)applicationWillTerminate:(UIApplication *)application
|
||||
{
|
||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||
// Create interface of ewol here ....
|
||||
NSLog(@"REMOVE EWOL interface destruction\n");
|
||||
IOs::releaseInterface();
|
||||
}
|
||||
/*
|
||||
- (void)dealloc {
|
||||
|
@ -18,8 +18,8 @@
|
||||
#include <ewol/resource/Manager.h>
|
||||
#include <ewol/context/Context.h>
|
||||
|
||||
#include <ewol/context/MacOs/Interface.h>
|
||||
#include <ewol/context/MacOs/Context.h>
|
||||
#include <ewol/context/IOs/Interface.h>
|
||||
#include <ewol/context/IOs/Context.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@ -55,11 +55,11 @@ private:
|
||||
public:
|
||||
MacOSInterface(int32_t _argc, const char* _argv[]) :
|
||||
ewol::Context(_argc, _argv) {
|
||||
//mm_main(_argc, _argv);
|
||||
// nothing to do ...
|
||||
}
|
||||
|
||||
int32_t Run(void) {
|
||||
return mm_run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
public:
|
||||
@ -120,14 +120,14 @@ MacOSInterface* interface = NULL;
|
||||
|
||||
|
||||
|
||||
bool MacOs::draw(bool _displayEveryTime) {
|
||||
bool IOs::draw(bool _displayEveryTime) {
|
||||
if (interface == NULL) {
|
||||
return false;
|
||||
}
|
||||
return interface->MAC_Draw(_displayEveryTime);
|
||||
}
|
||||
|
||||
void MacOs::resize(float _x, float _y) {
|
||||
void IOs::resize(float _x, float _y) {
|
||||
if (interface == NULL) {
|
||||
return;
|
||||
}
|
||||
@ -135,55 +135,65 @@ void MacOs::resize(float _x, float _y) {
|
||||
}
|
||||
|
||||
|
||||
void MacOs::setMouseState(int32_t _id, bool _isDown, float _x, float _y) {
|
||||
void IOs::setMouseState(int32_t _id, bool _isDown, float _x, float _y) {
|
||||
if (interface == NULL) {
|
||||
return;
|
||||
}
|
||||
interface->MAC_SetMouseState(_id, _isDown, _x, _y);
|
||||
}
|
||||
|
||||
void MacOs::setMouseMotion(int32_t _id, float _x, float _y) {
|
||||
void IOs::setMouseMotion(int32_t _id, float _x, float _y) {
|
||||
if (interface == NULL) {
|
||||
return;
|
||||
}
|
||||
interface->MAC_SetMouseMotion(_id, _x, _y);
|
||||
}
|
||||
|
||||
void MacOs::setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) {
|
||||
void IOs::setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) {
|
||||
if (interface == NULL) {
|
||||
return;
|
||||
}
|
||||
interface->MAC_SetKeyboard(_keyboardMode, _unichar, _isDown, _isAReapeateKey);
|
||||
}
|
||||
|
||||
void MacOs::setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown) {
|
||||
void IOs::setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown) {
|
||||
if (interface == NULL) {
|
||||
return;
|
||||
}
|
||||
interface->MAC_SetKeyboardMove(_keyboardMode, _move, _isDown);
|
||||
}
|
||||
|
||||
|
||||
static int l_argc = 0;
|
||||
static const char **l_argv = NULL;
|
||||
/**
|
||||
* @brief Main of the program
|
||||
* @param std IO
|
||||
* @return std IO
|
||||
*/
|
||||
int ewol::run(int _argc, const char *_argv[]) {
|
||||
etk::setArgZero(_argv[0]);
|
||||
/*
|
||||
interface = new MacOSInterface(_argc, _argv);
|
||||
l_argc = _argc;
|
||||
l_argv = _argv;
|
||||
return mm_main(_argc, _argv);
|
||||
}
|
||||
|
||||
// Creat and relaese ewol::Context interface:
|
||||
void IOs::createInterface(void) {
|
||||
etk::setArgZero(l_argv[0]);
|
||||
EWOL_INFO("Create new interface");
|
||||
interface = new MacOSInterface(l_argc, l_argv);
|
||||
if (NULL == interface) {
|
||||
EWOL_CRITICAL("Can not create the X11 interface ... MEMORY allocation error");
|
||||
return -2;
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t retValue = interface->Run();
|
||||
}
|
||||
|
||||
void IOs::releaseInterface(void) {
|
||||
if (interface == NULL) {
|
||||
return;
|
||||
}
|
||||
EWOL_INFO("Remove interface");
|
||||
delete(interface);
|
||||
*/
|
||||
int32_t retValue = mm_main(_argc, _argv);
|
||||
interface = NULL;
|
||||
return retValue;
|
||||
}
|
||||
|
||||
|
||||
@ -191,4 +201,3 @@ int ewol::run(int _argc, const char *_argv[]) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -11,7 +11,10 @@
|
||||
|
||||
#include <ewol/key/key.h>
|
||||
|
||||
namespace MacOs {
|
||||
namespace IOs {
|
||||
// Create and relaese ewol::Context interface:
|
||||
void createInterface(void);
|
||||
void releaseInterface(void);
|
||||
// return true if a flush is needed
|
||||
bool draw(bool _displayEveryTime);
|
||||
/**
|
||||
@ -25,4 +28,5 @@ namespace MacOs {
|
||||
void setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -14,7 +14,6 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
int mm_main(int argc, const char *argv[]);
|
||||
int mm_run(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -18,9 +18,3 @@ int mm_main(int argc, const char *argv[]) {
|
||||
} // return no error
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mm_run(void) {
|
||||
//[NSApp run];
|
||||
// return no error
|
||||
return 0;
|
||||
}
|
||||
|
@ -43,6 +43,5 @@
|
||||
- (void)stopAnimation;
|
||||
- (void)drawView;
|
||||
|
||||
- (void)setupView;
|
||||
|
||||
@end
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import <OpenGLES/EAGLDrawable.h>
|
||||
#include <ewol/context/IOs/Context.h>
|
||||
|
||||
#import "OpenglView.h"
|
||||
|
||||
@ -55,78 +56,26 @@
|
||||
}
|
||||
|
||||
animationInterval = 1.0 / 60.0;
|
||||
[self setupView];
|
||||
//self.bounds
|
||||
float width = [self frame].size.width;
|
||||
float height = [self frame].size.height;
|
||||
IOs::resize(width,height);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setupView {
|
||||
const GLfloat zNear = 0.1, zFar = 1000.0, fieldOfView = 60.0;
|
||||
GLfloat size;
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
size = zNear * tanf(DEGREES_TO_RADIANS(fieldOfView) / 2.0);
|
||||
|
||||
//Grab the size of the screen
|
||||
CGRect rect = self.bounds;
|
||||
glFrustumf(-size, size,
|
||||
-size / (rect.size.width / rect.size.height),
|
||||
size / (rect.size.width / rect.size.height),
|
||||
zNear, zFar);
|
||||
glViewport(0, 0, rect.size.width, rect.size.height);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
//Initialize touchLocation to 0, 0
|
||||
touchLocation = CGPointMake(160, 240);
|
||||
}
|
||||
|
||||
- (void)drawView {
|
||||
const GLfloat triangleVertices[] = {
|
||||
0.0, 1.0, -6.0, // top center
|
||||
-1.0, -1.0, -6.0, // bottom left
|
||||
1.0, -1.0, -6.0 // bottom right
|
||||
};
|
||||
|
||||
const GLfloat triangleColors[] = {
|
||||
1.0, 0.0, 0.0, 1.0, // red
|
||||
0.0, 1.0, 0.0, 1.0, // green
|
||||
0.0, 0.0, 1.0, 1.0, // blue
|
||||
};
|
||||
|
||||
//setting up the draw content
|
||||
[EAGLContext setCurrentContext:context];
|
||||
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
|
||||
|
||||
//Draw stuff
|
||||
|
||||
//clear the back color back to our original color and depth buffer
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
//reset matrix to identity
|
||||
glLoadIdentity();
|
||||
//rough approximation of screen to current 3D space
|
||||
GLfloat x = (touchLocation.x - 160.0) / 38.0;
|
||||
GLfloat y = (240.0 - touchLocation.y) / 38.0;
|
||||
//translate the triangle
|
||||
glTranslatef(x, y, -1.0);
|
||||
//set the format and location for verticies
|
||||
glVertexPointer(3, GL_FLOAT, 0, triangleVertices);
|
||||
//set the opengl state
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
//set the format and location for colors
|
||||
glColorPointer(4, GL_FLOAT, 0, triangleColors);
|
||||
//set the opengl state
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
//draw the triangles
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
|
||||
// Open GL draw : ...
|
||||
IOs::draw(true);
|
||||
glFlush();
|
||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
|
||||
//show the render buffer
|
||||
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
|
||||
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
|
@ -11,8 +11,7 @@
|
||||
|
||||
#include <ewol/key/key.h>
|
||||
|
||||
namespace MacOs {
|
||||
// return true if a flush is needed
|
||||
IOs // return true if a flush is needed
|
||||
bool draw(bool _displayEveryTime);
|
||||
/**
|
||||
* @brief The OS inform that the current windows has change his size.
|
||||
|
@ -63,11 +63,10 @@ def create(target):
|
||||
'ewol/context/MacOs/AppDelegate.mm'])
|
||||
elif target.name=="IOs":
|
||||
myModule.add_src_file([
|
||||
'ewol/context/MacOs/Context.cpp',
|
||||
'ewol/context/MacOs/Interface.mm',
|
||||
'ewol/context/MacOs/Windows.mm',
|
||||
'ewol/context/MacOs/OpenglView.mm',
|
||||
'ewol/context/MacOs/AppDelegate.mm'])
|
||||
'ewol/context/IOs/Context.cpp',
|
||||
'ewol/context/IOs/Interface.m',
|
||||
'ewol/context/IOs/OpenglView.mm',
|
||||
'ewol/context/IOs/AppDelegate.mm'])
|
||||
else:
|
||||
debug.error("unknow mode...")
|
||||
|
||||
@ -223,7 +222,15 @@ def create(target):
|
||||
"-framework OpenGL",
|
||||
"-framework QuartzCore",
|
||||
"-framework AppKit"])
|
||||
|
||||
elif target.name=="IOs":
|
||||
myModule.add_export_flag_LD([
|
||||
"-framework OpenGLES",
|
||||
"-framework CoreGraphics",
|
||||
"-framework UIKit",
|
||||
"-framework GLKit",
|
||||
"-framework Foundation",
|
||||
"-framework QuartzCore"])
|
||||
|
||||
# add the currrent module at the
|
||||
return myModule
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user