On Sat, Aug 15, 2009 at 5:46 AM, jaber <[email protected]> wrote:
> > Then how do I implement some class based on cocosnode to do the same > thing? > I mean, just use simple OpenGL draw functions. (glVertex, glColor, > etc) > > I just can't get used to subclassing Cocosnode yet > I tried many times but eventually messed up the cocos2d-opengl > rendering, then it won't show up > > > A CocosNode designed to draw something must care about: 1. get or sintethize the vertexes 2. get additional parameters ( colors, textures,...) 3. draw: i. set the appropriate gl state. ii. apply the transform, caring to push-pop the matrix iii. use the appropriate(d) gl function(s) to draw the object If your CocosNode subclass breaks other stock CocosNode objects drawing, then you may need to preserve some parts of gl state, using glPushAttrib with the appropriate flags before setting state and poping after drawing. I attached a very simple CocosNode subclass examples; for clarity it uses the gl inmediate mode to draw. I suggest you do your firsts CocosNode subclasses using inmediate mode; when you are sattisfied, if you tgink is too slow, then you can modify your code to use display lists or batches. And develop your subclass in a separate file, so that you will have simple code to ask for help. -- claudio --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "cocos2d discuss" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cocos-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
simple_cocosnodes.py
Description: Binary data
