Isometric game question

Started by
1 comment, last by Kwizatz 17 years, 7 months ago
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
Advertisement
When you post code, you can do it in [ source ] [ /source ] tags (without the spaces). It will make your example much more readable.

Also, gamedev has dedicated isometric, OpenGL, and NeHe forums.
XBox 360 gamertag: templewulf feel free to add me!
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.

This topic is closed to new replies.

Advertisement