Sign in to follow this  
ErikPeeters

Isometric game question

Recommended Posts

Hi All... I have set up a little OpenGL program, just to try isomteric tiling. I based my code on Lesson 20 of the NeHe OpenGL pages. Now i'm on the point of blending. The problem I have is that when I draw 2 textured quads with accompanying masks the black pixels of the image and mask are transparant but when the two textured quads overlap eachother with the not transparent colors they blend colors. The pictures of the buildings ar now blending together instead of lying ontop of eachother. The thing I want is that the second drawn texture is on top of the first drawn and not blend in with it. My code (texture[3] is the mask, texture[4] is the texture): int InitGL(GLvoid) { if(!LoadGLTextures()) return FALSE; glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0); glEnable(GL_DEPTH_TEST); glShadeModel(GL_SMOOTH); glEnable(GL_TEXTURE_2D); return TRUE; } int DrawGLScene(GLvoid) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0.0f, 0.0f, -1.0f); glEnable(GL_BLEND); glDisable(GL_DEPTH_TEST); if(masking) { glBlendFunc(GL_DST_COLOR,GL_ZERO); } if(masking) { glBindTexture(GL_TEXTURE_2D, texture[3]); glBegin(GL_QUADS); glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.1f,-0.1f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.1f,-0.1f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.1f, 0.1f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.1f, 0.1f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, texture[3]); glBegin(GL_QUADS); glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.15f,-0.1f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.05f,-0.1f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.05f, 0.1f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.15f, 0.1f, 0.0f); glEnd(); } glBlendFunc(GL_ONE, GL_ONE); glBindTexture(GL_TEXTURE_2D, texture[4]); glBegin(GL_QUADS); glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.1f,-0.1f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.1f,-0.1f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.1f, 0.1f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.1f, 0.1f, 0.0f); glEnd(); glBlendFunc(GL_ONE, GL_ONE); glBindTexture(GL_TEXTURE_2D, texture[4]); glBegin(GL_QUADS); glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.15f,-0.1f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.05f,-0.1f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.05f, 0.1f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.15f, 0.1f, 0.0f); glEnd(); glEnable(GL_DEPTH_TEST); glDisable(GL_BLEND); return TRUE; } Thank you for replying. - Erik

Share this post


Link to post
Share on other sites
Try setting the "Z" coordinate of your quads to different values for each, hint: quads with lower Z values will be drawn behind quads with higher Z values, if you are using an ortho projection matrix (like you should!), the actual screen sizes of the quads will not be affected.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this