Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question
    
How are you commiting drawn objects to screen? glClear? glFlush? glFinish? glSwapBuffers? –  sarahm Mar 30 '13 at 13:50
    
@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. –  besnep Mar 30 '13 at 14:03
    
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. –  Byte56 Mar 30 '13 at 14:19
    
No, the linked code does not answer my question. Although it looks like the framework you use takes care of the commiting step. –  sarahm Mar 30 '13 at 14:24
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
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. –  besnep Mar 30 '13 at 15:28
    
I edited my answer. –  sarahm Mar 30 '13 at 15:48
2  
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 =) –  Patrick Hughes Mar 30 '13 at 16:13
    
@sarahm : Thanks for this links. :) They are realy usefull for me to understant alot more of these things :) –  besnep Mar 30 '13 at 19:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.