objective c - Combining-OpenGL-ES-Cocos2d functionality -and-OpenGL-ES-(Unity 3d) navigation--within-iOS-app -


i developing app able run unity 3d navigation within using unityappcontroller , pause when not using navigation. main app have engine i.e cocos2d have other functionality.

now issue 3d navigation working if cocos2d(uses opengl-es) functionality not used, once used cocos2d functionality & again came 3d navigaton appears frozen. here app delegate(inherits unity appcontroller class) handling unity pause & play

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions{  [super application:application didfinishlaunchingwithoptions:launchoptions];   self.unityvc = [self getrootcontroller];  uibutton *button =[uibutton buttonwithtype:uibuttontypecustom]; [button setbackgroundcolor:[uicolor colorwithred:108.0/255 green:106.0/255 blue:55.0/255 alpha:1]]; [button settitle:@"done" forstate:uicontrolstatenormal]; //    [button settitlecolor:[uicolor blackcolor] forstate:uicontrolstatenormal]; [button setframe:frame]; [button addtarget:self action:@selector(fn_removeunity) forcontrolevents:uicontroleventtouchupinside]; [_rootview addsubview:button]; [_rootview bringsubviewtofront:button];   //default viewcontroller code //-------------------------------------------------------- //    self.window =  [uiapplication sharedapplication].keywindow;  self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; // override point customization after application launch.      [self fn_addmainscreen];  [self.window makekeyandvisible]; //--------------------------------------------------------      return yes;  }   - (void)playunity  {      [self unitypause:no];  }   - (void)pauseunity  {     [self unitypause:yes];   }   -(void) fn_addunity{     [window sethidden:yes];     [self playunity];  }   -(void) fn_removeunity{     [self pauseunity];     [window sethidden:no];     [self fn_addmainscreen];  } 

here cocos2d code

eaglview *glview = [eaglview viewwithframe:cgrectmake(md.glview_x,md.glview_y,md.glview_width,md.glview_height)                                pixelformat:keaglcolorformatrgb565   // keaglcolorformatrgba8                                depthformat:0                        // gl_depth_component16_oes                                preservebackbuffer:yes sharegroup:nil multisampling:no numberofsamples:nil                     ];  glview.autoresizingmask = uiviewautoresizingflexiblewidth | uiviewautoresizingflexibleheight; [[ccdirector shareddirector] setprojection:ccdirectorprojection2d]; [glview setcontentscalefactor:1.0]; [[ccdirector shareddirector]  enableretinadisplay:yes]; [[ccdirector shareddirector] setopenglview:glview]; [self.view insertsubview:glview atindex:0]; [[ccdirector shareddirector] runwithscene: [smoothningeffect scene]]; 

there can 1 opengl context active @ time, have shut down either engine when switch between them. then, both engines weren't designed cooperating other render engines, may prove impossible.

for example caching mechanisms may problem, in particular because cocos2d uses singletons on place keep things cached in memory. attempt make sure essential cocos2d singleton classes released memory before switching unity.

the question here rather why want mix 2 separate render engines in first place? one, unity has 2d toolset in itself. time better invested researching how whatever need in 2d unity's own 2d toolset, or emulating 2d in unity's 3d renderer many other games have done in past.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -