Jump to content
  • Advertisement
Sign in to follow this  
sasquach

OpenGL Making Object Disappear

This topic is 4071 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

I have a set of objects, and what I want to happen is once an object goes through the objects, I want the objects to disappear. Using OpenGL how can I do this?

Share this post


Link to post
Share on other sites
Advertisement
To make a object appear on screen there's things to do (setting up vertices, call a draw function),.. but to make a object disappear you just stop doing it and it won't be there if you don't tell OpenGL to draw it!

As for the object entering the other object, it's not really clear want. You might have to implement a complex collision detection algorithm or simply check the position of one object if it's < or > than the other,.. depending on what you want to do.

Share this post


Link to post
Share on other sites
I think you are asking how to make it fade out maybe? If so, turn blending on with glEnable(GL_BLEND); and gradually increase the alpha value on a glColor4f() call.

Share this post


Link to post
Share on other sites
I'm not sure where the glEnable goes. Does that go into my main function or does it go into the function where I'm drawing the object? I think I know where the glColor4f() goes that should go in the function where I'm drawing the object.

Share this post


Link to post
Share on other sites
glEnable goes where you initialize opengl and glColor4f goes before you draw the object. This can be accomplished by decreasing a varible that sets alpha every frame. But keep in mind that once the object is drawn you have to set back the alpha value to 1.
Also you might want to stop rendering object when alpha is 0 which will save some memory.

I feel you are not so experienced with OGL yet but hope you understood the above if no see the usage of glVolor4f and look for NeHe's blending tutorial.

-- Just to make sure you understand,
OpenGL renders all objects to memory then it sees which objects or parts of objects are visible or not and then puts lighting and etc giving the scene a 3d effect which is then shown on the monitor. This repeats for every frame hence not rendering objects makes them disappear in the frames after you stop rendering them.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!