Jump to content
  • Advertisement
Sign in to follow this  
EasyCoder

OpenGL Level Management in OpenGL ES

This topic is 2598 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 ?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Hidden

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() {
}
}

Share this post


Link to post

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() {
...
}
}

Share this post


Link to post
Share on other sites

[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 ?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!