quick question regarding translucency and GL_BLEND

Started by
11 comments, last by 3dnewbie 17 years, 4 months ago
Ok, thanks i will fix that then. Back to the original question, why do i get a quad that is divided into two triangles each with a different colour when turning blending on?
Advertisement
It's probably the way your two degenerate quads are being interpreted. If your gl just splits each quad into two triangles, one of which uses the first three vertices and the other the last three, then your two degenerate quads will generate four triangles, one of which will have zero size. Of the remaining three triangles, two will overlap, blending together to generate a different shade.

Σnigma
That makes sense. Thanks enigma. I seem to have fixed it thanks to your suggestions. However, now i have another weird problem which i can't seem to pinpoint: The grid lines i'm overlaying on top of the quad seem to be exact one row off!

For example, if the grid is facing me then the top row is simply blue without any grid and the bottom row has a row extra with a grid but now blue quad...

This is my new code. I'm not sure the quad is correct now, but when i display one it did correctly. I'm not sure it's done clockwise though.

GLvoid display_grid(GLvoid){           //			|//			|//	_____x_____x_______//			| //		 y	|  y	glBegin(GL_QUADS);	for(x=-10.0;x<GRID_SIZE;x+=SECTOR_SIZE) {	for(y=-10.0;y<GRID_SIZE;y+=SECTOR_SIZE) {	/* Set color for QUADS */	glColor4f(0.0f,0.0f,0.1,0.9f);	/* Draw QUADS */	glVertex3f(x,y,0); /* left side */   	glVertex3f(x+SECTOR_SIZE,y,0); /* rightside */ 	glVertex3f(x+SECTOR_SIZE,y-SECTOR_SIZE,0); /* upperside*/ 	glVertex3f(x,y-SECTOR_SIZE,0); /*lowerside */			}	}	glEnd();		glBegin(GL_LINES);	for(x=-10.0;x<GRID_SIZE;x+=SECTOR_SIZE) {	for(y=-10.0;y<GRID_SIZE;y+=SECTOR_SIZE) {	/* Set color for LINES */	glColor4f(0.0f,0.2f,0.0,1.0f);	/* Draw lines */	glVertex3f(x,y,0); /* Lower left */	glVertex3f(x,y+SECTOR_SIZE,0); /* To upper left */ 	glVertex3f(x,y+SECTOR_SIZE,0); /* Upper left */ 	glVertex3f(x+SECTOR_SIZE,y+SECTOR_SIZE,0); /* To upper right */	glVertex3f(x+SECTOR_SIZE,y+SECTOR_SIZE,0); /* Upper right */	glVertex3f(x+SECTOR_SIZE,y,0); /* To bottom right */	glVertex3f(x+SECTOR_SIZE,y,0); /* Bottom right */	glVertex3f(x,y,0); /* To Lower left */		}	}	glEnd();}

This topic is closed to new replies.

Advertisement