// Draw agent geometry with stroke, then fill polygons

The summer is almost over. I can't believe how quickly it went by. But I'm getting back into the swing of things by working diligently on my long-term research project.

OpenGL is freaking great! It is incredibly easy to work with and straightforward. I've heard all the arguments about how it isn't an excellent choice for game development, and I can see a lot of them; however, what I'm doing isn't necessarily that complex. Below is a screen shot of the scene which will play out the kinematic simulations. The playing field is the green checkered plane; the blue geometry is a placeholder for the AI agents that will run throughout the game.

To get the stroke effect on the agent's geometry, I ran two iterative calls to the glDrawArrays(); however, the first run-through avoids enabling GL_COLOR_ARRAY. It was a pretty simple process. The code is showcased below.

*** Part of DrawAgents() function ***

// ... the first array draws only the vertex geometry - NOT THE COLOR //
// (even though the color vertexes are packed next to geometry vertexes) //
glEnableClientState(GL_VERTEX_ARRAY);
// ENABLE THE VERTEX ARRAYS
glColor3f(
0, 0, 0); // SET THE OUTLINE (STROKE) COLOR AS BLACK
glVertexPointer(
3, GL_FLOAT, 6*sizeof(GLfloat), &agentModelArray[3]);

// Thicken the model's outline
glLineWidth(
2.0f);

// Draw the quad, geometry vertexes only...
glDrawArrays(GL_QUADS,
0, 4);
glDrawArrays(GL_TRIANGLES,
2, 3);

// Now enable the COLOR ARRAYS and fill the polygons
glEnableClientState(GL_COLOR_ARRAY);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glColorPointer(3, GL_FLOAT, 6*sizeof(GLfloat), &agentModelArray[0]);
glVertexPointer(3, GL_FLOAT, 6*sizeof(GLfloat), &agentModelArray[3]);

glDrawArrays
(GL_QUADS, 0, 4);
glDrawArrays(GL_TRIANGLES, 2, 3);

// Disable arrays

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);


Research_Screenshot_2