ios - Direct OpenGL ES 2.0 drawing over Cocos2d drawing -


i have got layer. has got children specific 'z' value. e.g.

  • child_1 z==-10.0f (ccsprite)
  • child_2 z==-5.0f (my custom node)
  • child_3 z==-1.0f (ccsprite)

my custom node (child_2) has direct opengl es invocation inside 'draw' method draw textures via shaders.

the issue stick with:

if add children in such steps ok:

[self addchild:child_1 z:-10.0f tag:1]; [self addchild:child_2 z:-5.0f tag:2]; [self addchild:child_3 z:-1.0f tag:3]; 

if add them in such way:

[self addchild:child_1 z:-10.0f tag:1]; [self addchild:child_3 z:-1.0f tag:3]; [self addchild:child_2 z:-5.0f tag:2]; 

child_3 not visible must be.

how use opengl es draw invocation proper drawing behaviour?

ps here code

[hm2 use]; glvertexattribpointer ( 0, 3, gl_float, gl_false, 0, vvertices2 ); glenablevertexattribarray ( 0 ); gldrawarrays ( gl_triangles, 0, 3 ); 

learncocos2d, thank you! have discovered ccdraw* , found there no gl* z value. mistake used gldrawarrays z-value. why did i? because wanted 2 different textures 1 of overlaps both of them should on child_1 , behind child_3. avoid issue stuck gldrawarrays shouldn't z-value.

in order avoid issue , make textures different depth inside child_2 guess solution create new 2 nodes , add them children child_2.

eg

@implementation child_2  ...  -(id) init { [self addchild:child_2_1 z:-1.0f tag:0]; [self addchild:child_2_2 z:-2.0f tag:1]; 

good luck!


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -