I have two draw functions - "drawComponents" and "drawSignals" which look as follows:
static void drawComponents(ARdouble trans1[3][4], ARdouble trans2[3][4], int r, int g, int b )
{
for (int i = 0; i < numComponents; i++){
glPushMatrix(); // Save world coordinate system.
glTranslatef(0.0f, 0.0f, 0.0f);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, &(components[i].combCoords[0]));
glColor4ub(r, g, b, 0);
glDrawElements(GL_LINES, components[i].nIndeces, GL_UNSIGNED_INT, &(components[i].combIndeces[0]));
glDisableClientState(GL_VERTEX_ARRAY);
glPopMatrix(); // Restore world coordinate system.
}
}
static void drawSignals(ARdouble trans1[3][4], ARdouble trans2[3][4], int r, int g, int b)
{
for (int i = 0; i < numSignals; i++)
{
glPushMatrix(); // Save world coordinate system.
glTranslatef(0.0f, 0.0f, 0.0f);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, signal[i].combCoords);
glColor4ub(r, g, b, 0);
glDrawElements(GL_LINES, signal[i].nIndeces, GL_UNSIGNED_INT, &(signal[i].combIndeces[0]));
glPopMatrix();
}
}
These functions work fine if i just call the directly in the MainLoop, however I want to call them based on user input. So if the "1" key is pressed then the drawComponents will be called, and if the "2" key is pressed the the drawSignals function will be called.
To do this I have the following keyEvent function:
static void keyEvent(unsigned char key, int x, int y)
{
switch (key) {
case '1':
drawComponents(config->trans, config->marker[3].trans, 255, 0, 0);
break;
case '2':
drawSignals(config->trans, config->marker[3].trans, 0, 0, 255);
break;
}
}
I thought would work fine, however with this function, nothing happens when I press the keys. Anyone have any suggestions as to where I'm going wrong