Skip to main content
expanded answer with knowledge requested in comment
Source Link
Exilyth
  • 1.4k
  • 10
  • 18

Usually, you have a list of objects. Each frame, you iterate over the list and call the current objects draw function. When you skip objects or remove them from the list, they don't get drawn.

So, either, in onSurfaceCreated, you would create the list of objects to draw and where you call

body.draw(gl);
eyes.draw(gl);
mouth.draw(gl);

in onDrawFrame you'd have to iterate over this list.

Then, outside the onDrawFrame Method, you could add/remove objects to/from the list to have them render or not.

Also, I'd recommend you to read 'Java ist auch eine Insel' from Gallileo Computing, freely available here: http://openbook.galileocomputing.de/javainsel/

Edit:

You might want to read up on matrix transforms and the opengl matrix stack.

Use one ViewMatrix to set your camera (like you're doing currently with GLUlookat), then use one modelmatrix per model to draw your objects in the right position.

Although it is for delphi and not for java, http://wiki.delphigl.com/index.php/Hauptseite is one of the best german opengl references.

http://wiki.delphigl.com/index.php/Hintergrundwissen has explanations for the background knowledge and http://wiki.delphigl.com/index.php/Tutorial is a series of tutorials.

Usually, you have a list of objects. Each frame, you iterate over the list and call the current objects draw function. When you skip objects or remove them from the list, they don't get drawn.

So, either, in onSurfaceCreated, you would create the list of objects to draw and where you call

body.draw(gl);
eyes.draw(gl);
mouth.draw(gl);

in onDrawFrame you'd have to iterate over this list.

Then, outside the onDrawFrame Method, you could add/remove objects to/from the list to have them render or not.

Also, I'd recommend you to read 'Java ist auch eine Insel' from Gallileo Computing, freely available here: http://openbook.galileocomputing.de/javainsel/

Usually, you have a list of objects. Each frame, you iterate over the list and call the current objects draw function. When you skip objects or remove them from the list, they don't get drawn.

So, either, in onSurfaceCreated, you would create the list of objects to draw and where you call

body.draw(gl);
eyes.draw(gl);
mouth.draw(gl);

in onDrawFrame you'd have to iterate over this list.

Then, outside the onDrawFrame Method, you could add/remove objects to/from the list to have them render or not.

Also, I'd recommend you to read 'Java ist auch eine Insel' from Gallileo Computing, freely available here: http://openbook.galileocomputing.de/javainsel/

Edit:

You might want to read up on matrix transforms and the opengl matrix stack.

Use one ViewMatrix to set your camera (like you're doing currently with GLUlookat), then use one modelmatrix per model to draw your objects in the right position.

Although it is for delphi and not for java, http://wiki.delphigl.com/index.php/Hauptseite is one of the best german opengl references.

http://wiki.delphigl.com/index.php/Hintergrundwissen has explanations for the background knowledge and http://wiki.delphigl.com/index.php/Tutorial is a series of tutorials.

Source Link
Exilyth
  • 1.4k
  • 10
  • 18

Usually, you have a list of objects. Each frame, you iterate over the list and call the current objects draw function. When you skip objects or remove them from the list, they don't get drawn.

So, either, in onSurfaceCreated, you would create the list of objects to draw and where you call

body.draw(gl);
eyes.draw(gl);
mouth.draw(gl);

in onDrawFrame you'd have to iterate over this list.

Then, outside the onDrawFrame Method, you could add/remove objects to/from the list to have them render or not.

Also, I'd recommend you to read 'Java ist auch eine Insel' from Gallileo Computing, freely available here: http://openbook.galileocomputing.de/javainsel/