So a subset of my code (within a rendering loop of course) is:
for(int x=0;x<data.length;x++)
for(int y=0;y<data[0].length;y++) {
float r = colorData[x][y][0], g = colorData[x][y][1], b = colorData[x][y][2];
glGetError();
glColor3f(r,g,b);
int xCoord = x*100;
int yCoord = y*100;
int height = (int) Math.round(data[y][x]*25);
glBegin(GL_QUADS);
//Top
glVertex3f(xCoord,yCoord,height);
glVertex3f(xCoord+100,yCoord,height);
glVertex3f(xCoord+100,yCoord+100,height);
glVertex3f(xCoord,yCoord+100,height);
//*/
//Sides
glColor3f(r/2,g/2,b/2);
glVertex3f(xCoord,yCoord,height);
glVertex3f(xCoord,yCoord,0);
glVertex3f(xCoord+100,yCoord,0);
glVertex3f(xCoord+100,yCoord,height);
glVertex3f(xCoord,yCoord+100,height);
glVertex3f(xCoord+100,yCoord+100,height);
glVertex3f(xCoord+100,yCoord+100,0);
glVertex3f(xCoord,yCoord+100,0);
glVertex3f(xCoord,yCoord+100,height);
glVertex3f(xCoord,yCoord+100,0);
glVertex3f(xCoord,yCoord,0);
glVertex3f(xCoord,yCoord,height);
glVertex3f(xCoord+100,yCoord+100,height);
glVertex3f(xCoord+100,yCoord,height);
glVertex3f(xCoord+100,yCoord,0);
glVertex3f(xCoord+100,yCoord+100,0);
//Bottom
glColor3f(r/4,g/4,b/4);
glVertex3f(xCoord,yCoord,0);
glVertex3f(xCoord,yCoord+100,0);
glVertex3f(xCoord+100,yCoord+100,0);
glVertex3f(xCoord+100,yCoord,0);
glEnd();
int err = glGetError();
if(err != GL_NO_ERROR)
System.out.println("An error has occured: #"+err);
glColor3f(1,0,0);
glBegin(GL_LINES);
//Top
glVertex3f(xCoord,yCoord,height);
glVertex3f(xCoord+100,yCoord,height);
glVertex3f(xCoord+100,yCoord+100,height);
glVertex3f(xCoord,yCoord+100,height);
glEnd();
}
The code works correctly, drawing a two dimensional grid of boxes, with the sides of the box being slightly darker than the top. (Poor man's lighting)
Just for curiosity I took out the first call to glColor3f, expecting the top of the box to become colorless, and the sides to remain the same; however the entire grid of boxes goes white. Why is this? Is it something in this code here? Or is some other part of my render loop causing this?
(If it makes a difference, I'm using LWJGL's Java implementation of OpenGL1.1)