I have some c++ game code that draws the game state on each game-loop cycle in "immediate mode". By that I mean that the game code does not add the sprites to be drawn to any sort of "scene graph" or other data structure. It just starts from a blank slate on each game loop cycle, and piles on the sprites from back to front. (I know you might wonder what API this c++ code is actually using. Well, it's written in Marmalade, which I'm moving away from. Marmalade provides an abstraction layer and the essence of this question is about replacing that abstraction layer.)
I am having trouble understanding what "immediate mode" really means in opengl es, and how it relates to the "fixed function" vs. "programmable" pipeline. Some things I read say, don't use the old immediate mode functions, use the modern shader-based programmable API instead." But at the same time, I believe glDrawArrays() is fine to use in opengl es 2.0, right? So that's an "immediate mode" function.
(I believe what's going on here is that "immediate mode" means different things at different levels. My understanding is that a library like cocosd2-x is "retained mode" in that you add sprites to a scene graph that's managed by the engine. But at the opengl level itself, I think "immediate mode" means something a bit different, namely whether you keep the vital drawing structures in CPU space until you draw them with a begin() end() sandwich, versus uploading them ahead of time to the GPU. So it that sense the GPU "retains" your data across calls. But still, you can draw a frame in "immediate" mode in the sense of piling on sprites one at a time using glDrawArrays() as many times as necessary.)
In the "hello world" example of cocos2d-x, we see
// add the sprite as a child to this layer this->addChild(sprite, 0);
That is exactly what I don't want to have to do, because as I say, my code base is set up not thinking of the sprites as objects, but just as drawing a bunch of rectangles from texture sheets (atlases) stacked on top of each other. I don't want to think of adding sprites to some scene graph and "letting the engine take care of it." That may be a fine way of thinking in general, but it would involve a huge rewrite of my existing code.
On the other hand, I think I like the idea of cocos2d-x because it gives me a convenient way to develop a code base that I can develop on Windows and run on iPhone, Android, and elsewhere.
So what I'm trying to understand is: Can I use cocos2d-x in some "immediate mode" fashion?
Basically, in opengles 2.0, I am allowed to call glDrawArrays(), correct? And if I batch up my sprites in a reasonable way, I can limit the number of calls to glDrawArrays() in each frame. So I want to do that, and I'm fine writing that gl code myself. But I think even though perhaps this defeats some of the point of using cocos2d-x in the first place, there are still huge portability and not-reinventing-the-wheel advantages of using cocos2s-x vs writing things from scratch myself?
So can I use cocos2s-x in that "immediate mode" way, and still retain the write-once/run-everywhere benefits?