Level Management in OpenGL ES

Started by
11 comments, last by swiftcoder 12 years, 5 months ago
What is the best way of Level Management in OpenGL ES ???

i.e. you want to have a game with let say 100 different levels, each level using multiple and different instances of rendered objects.

If you would have everything in one Renderer, I presume it would take up lot of resources and you might run out of memory quickly, also there is a limitation on a sub size in Java.

It would make sense to activate for each level only those objects which you need for that particular level and release all those objects for previous level which you no longer require.

So what is the best way to go round this ?

Could you for example have multiple Renderers, for each level one ?
Advertisement
Well u can make a class which defines a level and than give them arrays of the objects u will use


class CMap
{
public:
NPCS *npcs[max_npcs];
Objects *objects[max_objects];
Enemys *enemys[max_enemys]];

bool load();
bool clearMem();

void render();
}


and than allocate them when a level loads and deallocate them when a level is finished


CMap::load
{
for (i < objects_needed)
objects = new Objects();

... same for npcs and enemys

initializeAllObjectsWithValues(*npcs, *objects, *enemys);
}

CMap::clearMem
{
for (i < objects_needed)
delete objects

..same for npcs and enemys
}


CMap render()
{
renderObjects(*npcs, *enemys, *objects);
}




I don't know how to do that in java but in C its pretty easy.
THis way u only have in memory what u actually need ..

Maybe that helped you, if u need further explanation quote this post :-)

peace

I open sourced my C++/iOS OpenGL 2D RPG engine :-)



See my blog: (Tutorials and GameDev)


[size=2]http://howtomakeitin....wordpress.com/

The way i do it my current project is as follows:

i got 4 core classes:

Renderer
Game Model
Entity
Renderable

The Game Model runs the simulation and loads its data from the level files, The entities exist in the game model and are built from several parts, the important one here is the Renderable class.

The Renderer gets a list of pointers to renderable objects (Which are the same ones as used by the entities in the game model) and renders those (it can sort the pointers as it pleases to get the rendering done in a good order), renderable objects consist of material, effects, matrices, mesh, etc aswell as active and 2 priority values). (Naturally the renderable object stores IDs for materials etc rather than the details), a list of all resources (materials, effects, meshes) used in a level is passed to the renderer at the start of each level to be loaded onto the gpu, if there isn't enough VRAM for all resources the renderer can use the active and priority values to decide which Renderable objects resources to keep on the GPU at a given time and which renderables to cut out completely)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
Thanks for the suggestions, but the above solutions refer to Open GL / C++ Development, which I cannot implement.

Anybody has any experiences in Game Level Management in OpenGL ES / Java, preferably on Android ?
Why would you not be able to implement either of the above systems?
The concepts are exactly the same with a very minor change to syntax.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

pointer arithmetics in java?

I open sourced my C++/iOS OpenGL 2D RPG engine :-)



See my blog: (Tutorials and GameDev)


[size=2]http://howtomakeitin....wordpress.com/


pointer arithmetics in java?


The use of pointers is a minor implementation detail.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

pointer arithmetics in java?


You don't have to use pointers, you can either use a plain variable or a collection class in place of a pointer. For xample CMap would look like this:

class CMap
{
public NPCS npcs[][max_npcs];
Objects objects[][max_objects];
Enemys enemys[][max_enemys]];

public Boolean load() {
...
}

public Boolean clearMem() {

}

public void render() {
}
}
Want to make Android Games?
Then check out the free RoboBrain SDK.
[size="2"][url="http://www.robobrain.org"]www.robobrain.org[/url]

pointer arithmetics in java?


You don't have to use pointers, you can either use a plain variable or a collection class in place of a pointer. For example CMap would look like this:

class CMap
{
public NPCS npcs[max_npcs];
public Objects objects[max_objects];
public Enemys enemys[max_enemys]];

public Boolean load() {
...
}

public Boolean clearMem() {
...
}

public void render() {
...
}
}
Want to make Android Games?
Then check out the free RoboBrain SDK.
[size="2"][url="http://www.robobrain.org"]www.robobrain.org[/url]

[quote name='FlyingDutchman' timestamp='1319374415' post='4875598']
pointer arithmetics in java?


You don't have to use pointers, you can either use a plain variable or a collection class in place of a pointer. For example CMap would look like this:

class CMap
{
public NPCS npcs[max_npcs];
public Objects objects[max_objects];
public Enemys enemys[max_enemys]];

public Boolean load() {
...
}

public Boolean clearMem() {
...
}

public void render() {
...
}
}

[/quote]

I got that far, but how you would go round releasing the object which you don't need for a particular level.

I was reading somewhere, that simply setting the object to null (i.e. ObjectNotNeeded = null;) does not clear the Android memory.

Is that true ? And if so, how to go round this problem ?

This topic is closed to new replies.

Advertisement