[DEV] start dev on MACOS interface

This commit is contained in:
Edouard DUPIN 2013-04-04 00:43:03 +02:00
parent feb1ed56af
commit ca352c94d9
9 changed files with 374 additions and 20 deletions

View File

@ -29,16 +29,8 @@ endif
LOCAL_C_INCLUDES :=
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS := -lGL
LOCAL_EXPORT_LDLIBS := -framework OpenGL
#`pkg-config --cflags directfb` `pkg-config --libs directfb`
ifeq ("$(CONFIG___EWOL_LINUX_GUI_MODE_X11__)","y")
LOCAL_EXPORT_LDLIBS += -lX11
endif
ifeq ("$(CONFIG___EWOL_LINUX_GUI_MODE_DIRECT_FB__)","y")
LOCAL_EXPORT_LDLIBS += -L/usr/local/lib -ldirectfb -lfusion -ldirect
endif
#http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Introduction
# needed package on linux : libgl1-mesa-dev libglew1.5-dev
@ -55,13 +47,10 @@ include $(LOCAL_PATH)/file.mk
LOCAL_SRC_FILES := $(FILE_LIST)
ifeq ("$(CONFIG___EWOL_LINUX_GUI_MODE_X11__)","y")
LOCAL_SRC_FILES += ewol/renderer/os/gui.X11.cpp
endif
ifeq ("$(CONFIG___EWOL_LINUX_GUI_MODE_DIRECT_FB__)","y")
LOCAL_CFLAGS += -I/usr/local/include/directfb
LOCAL_SRC_FILES += ewol/renderer/os/gui.directFB.cpp
endif
LOCAL_SRC_FILES += ewol/renderer/os/gui.MacOs.cpp \
ewol/renderer/os/gui.MacOs.Interface.mm \
ewol/renderer/os/gui.MacOs.AppDelegate.mm \
ewol/renderer/os/gui.MacOs.OpenglView.mm
include $(BUILD_STATIC_LIBRARY)

View File

@ -49,6 +49,10 @@ extern "C" {
#error you need to specify a __TAGET_OS__ ...
#endif
#ifdef __cplusplus
}
#endif
namespace ewol {
namespace openGL {
/**
@ -178,9 +182,5 @@ namespace ewol {
};
};
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,10 @@
#import <UIKit/UIKit.h>
@interface MacOsAppDelegate : NSObject <UIApplicationDelegate> {
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@end

View File

@ -0,0 +1,65 @@
#import <ewol/renderer/os/gui.MacOs.AppDelegate.h>
#import <ewol/renderer/os/gui.MacOs.OpenglView.h>
@implementation MacOsAppDelegate
@synthesize window=_window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
OpenglView *view=[[OpenglView alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
[self.window addSubview:view];
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
*/
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
/*
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application
{
/*
Called when the application is about to terminate.
Save data if appropriate.
See also applicationDidEnterBackground:.
*/
}
- (void)dealloc
{
[_window release];
[super dealloc];
}
@end

View File

@ -0,0 +1,9 @@
#ifndef __MM_INTERFACE_H__
#define __MM_INTERFACE_H__
int mm_main(int argc, char *argv[]);
#endif

View File

@ -0,0 +1,14 @@
#import <UIKit/UIKit.h>
int mm_main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}

View File

@ -0,0 +1,16 @@
#import <UIKit/UIKit.h>
#import <OpenGLES/ES2/gl.h>
#import <QuartzCore/QuartzCore.h>
@interface OpenglView : UIView {
EAGLContext *mimContext;
@private
GLuint framebuffer;
GLuint renderbuffer;
}
- (void)drawView;
@end

View File

@ -0,0 +1,67 @@
#import <ewol/renderer/os/gui.MacOs.OpenglView.h>
@implementation OpenglView
+ (Class) layerClass
{
return [CAEAGLLayer class];
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
CAEAGLLayer* eaglLayer = (CAEAGLLayer*) super.layer;
eaglLayer.opaque = YES;
mimContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
BOOL setContext=[EAGLContext setCurrentContext:mimContext];
if (!mimContext || !setContext)
{
[self release];
return nil;
}
//Lets init and bind render buffer with current context
glGenRenderbuffers(1, &renderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
[mimContext renderbufferStorage:GL_RENDERBUFFER fromDrawable: eaglLayer];
//Frame buffer- which is a collection of render buffers and other kind of buffers like depth etc.
glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glFramebufferRenderbuffer(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer);
//Setting the dimensions of your view area.
glViewport(0, 0, CGRectGetWidth(frame), CGRectGetHeight(frame));
[self drawView];
}
return self;
}
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawView
{
// Drawing code
glClearColor(1.0f, 0.0f, 1.0f, 1);
glClear(GL_COLOR_BUFFER_BIT);
[mimContext presentRenderbuffer:GL_RENDERBUFFER];
}
- (void)dealloc
{
[super dealloc];
}
@end

View File

@ -6,3 +6,187 @@
* @license BSD v3 (see license file)
*/
#include <ewol/debug.h>
#include <ewol/ewol.h>
#include <ewol/key.h>
#include <ewol/config.h>
#include <ewol/commandLine.h>
#include <etk/UString.h>
#include <etk/unicode.h>
#include <ewol/widget/WidgetManager.h>
#include <ewol/renderer/os/gui.h>
#include <ewol/renderer/ResourceManager.h>
#include <ewol/renderer/os/eSystem.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/times.h>
#include <mach/clock.h>
#include <mach/mach.h>
int64_t guiInterface::GetTime(void)
{
struct timespec now;
clock_serv_t cclock;
mach_timespec_t mts;
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock);
now.tv_sec = mts.tv_sec;
now.tv_nsec = mts.tv_nsec;
//EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_nsec/(int64_t)1000);
}
#undef __class__
#define __class__ "guiInterface"
static ewol::SpecialKey guiKeyBoardMode;
/**
* @brief Set the new title of the windows
* @param title New desired title
* @return ---
*/
void guiInterface::SetTitle(etk::UString& title)
{
EWOL_INFO("X11: Set Title (START)");
EWOL_INFO("X11: Set Title (END)");
}
void guiInterface::SetIcon(etk::UString inputFile)
{
EWOL_TODO("plop");
}
void RemoveDecoration(void)
{
EWOL_TODO("X11:RemoveDecoration");
}
void AddDecoration(void)
{
EWOL_TODO("X11:AddDecoration");
}
// -------------------------------------------------------------------------
// ClipBoard AREA :
// -------------------------------------------------------------------------
void guiInterface::ClipBoardGet(ewol::clipBoard::clipboardListe_te clipboardID)
{
}
void guiInterface::ClipBoardSet(ewol::clipBoard::clipboardListe_te clipboardID)
{
}
#undef __class__
#define __class__ "guiInterface"
void guiInterface::Stop(void)
{
EWOL_INFO("X11-API: Stop");
}
void guiInterface::KeyboardShow(void)
{
// nothing to do : No keyboard on computer ...
}
void guiInterface::KeyboardHide(void)
{
// nothing to do : No keyboard on computer ...
}
void guiInterface::ChangeSize(ivec2 size)
{
EWOL_INFO("X11-API: ChangeSize=" << size);
}
void guiInterface::ChangePos(ivec2 pos)
{
EWOL_INFO("X11-API: ChangePos=" << pos);
}
void guiInterface::GetAbsPos(ivec2& pos)
{
EWOL_INFO("X11-API: GetAbsPos");
}
// select the current cursor to display :
static ewol::cursorDisplay_te l_currentCursor = ewol::cursorArrow;
void guiInterface::SetCursor(ewol::cursorDisplay_te newCursor)
{
if (newCursor != l_currentCursor) {
EWOL_DEBUG("X11-API: Set New Cursor : " << newCursor);
// set the new one :
l_currentCursor = newCursor;
}
}
void guiInterface::GrabPointerEvents(bool isGrabbed, vec2 forcedPosition)
{
}
#include <ewol/renderer/os/gui.MacOs.Interface.h>
/**
* @brief Main of the program
* @param std IO
* @return std IO
*/
int guiInterface::main(int argc, const char *argv[])
{
//start the basic thread :
eSystem::Init();
// Run ...
int ret = mm_main(argc, argv);
EWOL_INFO("Return main value=" << ret);
// close X11 :
guiInterface::Stop();
// uninit ALL :
eSystem::UnInit();
return 0;
}
void guiInterface::ForceOrientation(ewol::orientation_te orientation)
{
// nothing to do ...
}