Artifacts while trying to draw a Quad with Triangles

Hi guys,

The issue I have is that I am trying to draw 2 triangles as a quad and texture over it. Drawing the font seems to work no problem but when trying to draw a textured tile it doesn’t seem to. If I draw with the following code:

void OGL_Renderer_3_2::drawVertexArray(GLuint textureId, bool defaultTextureCoords){
	//clearScreen(0, 0, 0);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	glUseProgram(mShaderManager->getShaderProgram());
	getError();
	
	mModelViewMatrix = glGetUniformLocation(mShaderManager->getShaderProgram(), "mvp");
	getError();
	
	glUniformMatrix4fv(mModelViewMatrix, 1, GL_FALSE, glm::value_ptr(ModelViewMatrix));
	getError();
	


	glActiveTexture(GL_TEXTURE0 + textureId);
	glBindTexture(GL_TEXTURE_2D, textureId);
	
	
	GLint texUnitLoc = glGetUniformLocation(mShaderManager->getShaderProgram(), "tex0");
	glUniform1i(texUnitLoc, textureId);
	
	glBindVertexArray(mVertexArray);
	getError();


	glDrawArrays(GL_TRIANGLES, 0, 6);
	getError();


	glBindVertexArray(0);
	getError();
	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, 0);
	getError();
	glUseProgram(0);
	getError();
	glDisable(GL_BLEND);
}

I get this screen:
[ATTACH=CONFIG]383[/ATTACH]

if I change glDrawArrays to 5 vertices (using either TriangleStrips or Triangles) I get this:
[ATTACH=CONFIG]384[/ATTACH]

Here is the vertex function where the triangles get their data:

/** * Used internally to fill the vertex array with quad vertex information.
 */
void OGL_Renderer_3_2::fillVertexArray(GLfloat x, GLfloat y, GLfloat w, GLfloat h)
{
	mVertexArrayData[0] = static_cast<GLfloat>(x); mVertexArrayData[1] = static_cast<GLfloat>(y + h); mVertexArrayData[2] = 0.0;
	mVertexArrayData[3] = static_cast<GLfloat>(x); mVertexArrayData[4] = static_cast<GLfloat>(y); mVertexArrayData[5] = 0.0;
	mVertexArrayData[6] = static_cast<GLfloat>(x + w); mVertexArrayData[7] = static_cast<GLfloat>(y); mVertexArrayData[8] = 0.0;
	mVertexArrayData[9] = static_cast<GLfloat>(x + w); mVertexArrayData[10] = static_cast<GLfloat>(y); mVertexArrayData[11] = 0.0;
	mVertexArrayData[12] = static_cast<GLfloat>(x);	mVertexArrayData[13] = static_cast<GLfloat>(y + h); mVertexArrayData[14] = 0.0;
	mVertexArrayData[15] = static_cast<GLfloat>(x + w);	mVertexArrayData[16] = static_cast<GLfloat>(y + h); mVertexArrayData[17] = 0.0;
	


	glBindBuffer(GL_ARRAY_BUFFER, mVertexBufferObject);
	getError();
	glBufferData(GL_ARRAY_BUFFER, 3 * 6 * sizeof(GLfloat), mVertexArrayData, GL_DYNAMIC_DRAW);
	getError();
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	getError();
	glBindBuffer(GL_ARRAY_BUFFER, NULL);
	getError();
	glFlush();
	getError();
}

My instinct tells me that there is extra data or garbled data but I can’t see where I would have bogus data.

No thoughts? Am I leaving anything out? Much appreciated!

Your image is very small. Are you talking about the quad in the top left?

If so drawing with 5 vertices and GL_TRIANGLES will only give you 1 triangle from the first 3 vertices since the other 2 do not complete a triangle and your vertices are wrong for a strip.