Hello,
I'm running out of ideas trying to debug an issue with a basic line render in the form of a 'world axis' model.
The idea is simple:
I create a VAO with float line vertices (3 per vertex), int indices (1 per vertex), and unsigned byte color (3 per vertex)
I allow room and pack the array such that the first 12 vertices/indices/colors are for uniquely colored lines representing my +- world axis, and then a bunch of lines forming a 2D grid across the XZ plane.
Once data is loaded, I render by binding my VAO, activating a basic shader then drawing the model in two stages. One glDrawElements call is made for the axis lines after glLineWidth is set to 2, and the grid lines drawn through a separate glDrawElements with thinner lines.
Whenever I Draw this way, the last 6 lines of my grid (i.e. the end of the VAO array) show up as random colors. However, the lines themselves are correctly positioned, etc. If I just do one glDrawElements call for all lines (ie world axis and grid lines at once), then the entire model appears as expected with correct colors everywhere.
This is only an issue on some ATI cards (ie radeon mobility 5650), but works on NVidia no problem.
I can't see what I would have done wrong if the lines are appearing fine (ie my VAO index counts/offsets must be ok for glDrawElements), and I don't see how it could be that I'm somehow packing the data into the VAO wrong if they appear correctly via a single glDrawElements call instead of two calls separated by changes to glLineWidth()?
Any suggestions? glGetError, etc return no problems at all...
Here is some example render code, although I know it is just a small piece of the overall picture. This causes the problem:
TFloGLSL_IndexArray *tmpIndexArray = m_VAOAttribs->GetIndexArray();
//The first AXIS_MODEL_BASE_INDEX_COUNT elements are for the base axis..draw these thicker
glLineWidth(2.0f);
glDrawElements(GL_LINES, AXIS_MODEL_BASE_INDEX_COUNT,
GL_UNSIGNED_INT, (GLvoid*)tmpIndexArray->m_VidBuffRef.m_GLBufferStartByte);
//The first remaining elements are for the base grid..draw these thin
int gridLinesElementCount = m_VAOAttribs->GetIndexCount() - AXIS_MODEL_BASE_INDEX_COUNT;
if(gridLinesElementCount > 0)
{
glLineWidth(1.0f);
glDrawElements(GL_LINES, gridLinesElementCount, GL_UNSIGNED_INT,
(GLvoid*)(tmpIndexArray->m_VidBuffRef.m_GLBufferStartByte + (AXIS_MODEL_BASE_INDEX_COUNT * sizeof(int))));
}
This works just fine:
glDrawElements(GL_LINES, m_VAOAttribs->GetIndexCount(), GL_UNSIGNED_INT,
(GLvoid*)tmpIndexArray->m_VidBuffRef.m_GLBufferStartByte);