1
\$\begingroup\$

With OpenGL i'm drawing for example a circle.

Can i take this drawn circle back out of the window and change something and then draw it back on the window?

Or can i /have to delete it and then draw it new with other properties?

Do someone have me a link etc how to do something like this?

edit it is just about 2D objects

\$\endgroup\$
4
  • \$\begingroup\$ How are you commiting drawn objects to screen? glClear? glFlush? glFinish? glSwapBuffers? \$\endgroup\$
    – Exilyth
    Commented Mar 30, 2013 at 13:50
  • \$\begingroup\$ @Sarahm : Here you can finde the code from an GLObject from me: gamedev.stackexchange.com/questions/52934/… and hier the code of my renderer: gamedev.stackexchange.com/questions/52985/… if this is answering your question. \$\endgroup\$
    – Spenhouet
    Commented Mar 30, 2013 at 14:03
  • \$\begingroup\$ You're not going to get the object back once you've sent it to the graphics card. You need to modify your inputs and rebuild your buffers. \$\endgroup\$
    – House
    Commented Mar 30, 2013 at 14:19
  • \$\begingroup\$ No, the linked code does not answer my question. Although it looks like the framework you use takes care of the commiting step. \$\endgroup\$
    – Exilyth
    Commented Mar 30, 2013 at 14:24

1 Answer 1

2
\$\begingroup\$

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.

\$\endgroup\$
4
  • \$\begingroup\$ That sounds like i did everything or alot wrong :( I thought the OpenGL is creating graphical objects out of the vertices list i made and i can modify this objects. So i have to make lists for every object and then change the cordinates in this list or? Sounds very inconvenient. Thx for the tip with the book (and recognizing that i'm german), but i don't have any time for that, i just need to fix my problems and my miss understandings. So if you have any tutorial etc related to my problems i woud be very thankfull. \$\endgroup\$
    – Spenhouet
    Commented Mar 30, 2013 at 15:28
  • \$\begingroup\$ I edited my answer. \$\endgroup\$
    – Exilyth
    Commented Mar 30, 2013 at 15:48
  • 2
    \$\begingroup\$ You really need to start with a "from the ground up" tutorial on OpenGL, you can't make assumptions on how the system magically works. That's kind of like pouring eggs into a toaster expecting them to come out scrambled because you heard that toasters cook things =) \$\endgroup\$ Commented Mar 30, 2013 at 16:13
  • \$\begingroup\$ @sarahm : Thanks for this links. :) They are realy usefull for me to understant alot more of these things :) \$\endgroup\$
    – Spenhouet
    Commented Mar 30, 2013 at 19:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .