Jump to content
  • Advertisement
Sign in to follow this  
justinxnitsuj

glass effect

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

hi! i'm trying to make a window for my house. i put the glass texture and i enable gl_blend for the window. but then all the things are affected. how can i prevent it ? or have i to do it in another way ? here is the code : void DrawWindow (float x,float y,float z){ glPushMatrix(); glEnable(GL_BLEND); glTranslatef(x,y,z); glBindTexture(GL_TEXTURE_2D, texture[9]); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex3f(-5.0f, -5.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 5.0f, -5.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 5.0f, 5.0f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-5.0f, 5.0f, 0.0f); glEnd(); glPopMatrix(); } ............... DrawWindow (-16.0f,0.0f,30.0f);

Share this post


Link to post
Share on other sites
Advertisement
You just need to put glDisable(GL_BLEND) near the end of the window render, just before glPopMatrix() would be fine.

Share this post


Link to post
Share on other sites
glEnable(...) and other functions change the state of the OpenGL state machine permanently, so unless you glDisable(...) blending after using it, all objects drawn after the window will be blended (this means all objects in the following frames if you don't ever disable blending).

Just call glDisable(GL_BLEND) after drawing the window for a simple solution.

Better: group the objects that need blending, enable it once, draw all the objects, disable blending one. This way you reduce state changes in OpenGL which can be very expensive in terms of performance. Keep in mind that other states may be more expensive so optimize your rendering order to reduce the most expensive state changes first.

Share this post


Link to post
Share on other sites
thanks for the help :)
but there is a problem. from inside the effect is good, but from outside the effect looks terrible (i guess from the texture inside) can i configure the intensity of the effect ?

Share this post


Link to post
Share on other sites
try adding glDisable(GL_DEPTH_TEST); when rendering your window

(yes, I know, I know, he should be sorting his objects according to their depth, but let's see if this works first)

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!