• Advertisement
Sign in to follow this  

Isometric game question

This topic is 4187 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 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
Advertisement
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
Sign in to follow this  

  • Advertisement