Here is my source code so I don't lose it! And with comments that hopefully will clear things up for myself when I look at it down the road.
void display()
{
glClearColor(1,1,1,1); // made the background white
glClear(GL_COLOR_BUFFER_BIT); // not sure what this does but it doesn't clear properly without it
glBegin(GL_LINES);
// draws red part
glColor3f(1.0, 0.0, 0.0);
glVertex3f(-1.0, 0.5, 0.0);
glVertex3f(0.0, 0.55, 0.0);
glVertex3f(0.0, 0.55, 0.0);
glVertex3f(1.0, 0.5, 0.0);
// draws orange part
glColor3f(1.0, 0.5, 0.0);
glVertex3f(-1.0, 0.45, 0.0);
glVertex3f(0.0, 0.5, 0);
glVertex3f(0.0, 0.5, 0.0);
glVertex3f(1.0, 0.45, 0);
// draws yellow part
glColor3f(1.0, 1.0, 0.0);
glVertex3f(-1.0, 0.40, 0.0);
glVertex3f(0.0, 0.45, 0);
glVertex3f(0.0, 0.45, 0.0);
glVertex3f(1.0, 0.40, 0);
// draws green part
glColor3f(0.0, 1.0, 0.0);
glVertex3f(-1.0, 0.35, 0.0);
glVertex3f(0.0, 0.4, 0);
glVertex3f(0.0, 0.4, 0.0);
glVertex3f(1.0, 0.35, 0);
// draws blue part
glColor3f(0.0, 0.0, 1.0);
glVertex3f(-1.0, 0.3, 0.0);
glVertex3f(0.0, 0.35, 0.0);
glVertex3f(0.0, 0.35, 0.0);
glVertex3f(1.0, 0.3, 0.0);
// draws purple part
glColor3f(1.0, 0.0, 1.0);
glVertex3f(-1.0, 0.25, 0.0);
glVertex3f(0.0, 0.3, 0);
glVertex3f(0.0, 0.3, 0);
glVertex3f(1.0, 0.25, 0);
// every begin needs a matching end
// every specific shape needs a separate begin, end (can't draw triangles in between this, for example)
glEnd();
glutSwapBuffer(); // not sure what this does but without it, the entire image becomes white
}
int main(int argc, char** argv)
{
glutInit(&argc, argv); // still worked when this was commented out.. hmm..
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutInitWindowSize(600,600);
glutCreateWindow("not a rainbow but i can still pretend");
glutDisplayFunc(display);
glutMainLoop(); // no compiler errors when this was off but it just closed after a second
}
{
glClearColor(1,1,1,1); // made the background white
glClear(GL_COLOR_BUFFER_BIT); // not sure what this does but it doesn't clear properly without it
glBegin(GL_LINES);
// draws red part
glColor3f(1.0, 0.0, 0.0);
glVertex3f(-1.0, 0.5, 0.0);
glVertex3f(0.0, 0.55, 0.0);
glVertex3f(0.0, 0.55, 0.0);
glVertex3f(1.0, 0.5, 0.0);
// draws orange part
glColor3f(1.0, 0.5, 0.0);
glVertex3f(-1.0, 0.45, 0.0);
glVertex3f(0.0, 0.5, 0);
glVertex3f(0.0, 0.5, 0.0);
glVertex3f(1.0, 0.45, 0);
// draws yellow part
glColor3f(1.0, 1.0, 0.0);
glVertex3f(-1.0, 0.40, 0.0);
glVertex3f(0.0, 0.45, 0);
glVertex3f(0.0, 0.45, 0.0);
glVertex3f(1.0, 0.40, 0);
// draws green part
glColor3f(0.0, 1.0, 0.0);
glVertex3f(-1.0, 0.35, 0.0);
glVertex3f(0.0, 0.4, 0);
glVertex3f(0.0, 0.4, 0.0);
glVertex3f(1.0, 0.35, 0);
// draws blue part
glColor3f(0.0, 0.0, 1.0);
glVertex3f(-1.0, 0.3, 0.0);
glVertex3f(0.0, 0.35, 0.0);
glVertex3f(0.0, 0.35, 0.0);
glVertex3f(1.0, 0.3, 0.0);
// draws purple part
glColor3f(1.0, 0.0, 1.0);
glVertex3f(-1.0, 0.25, 0.0);
glVertex3f(0.0, 0.3, 0);
glVertex3f(0.0, 0.3, 0);
glVertex3f(1.0, 0.25, 0);
// every begin needs a matching end
// every specific shape needs a separate begin, end (can't draw triangles in between this, for example)
glEnd();
glutSwapBuffer(); // not sure what this does but without it, the entire image becomes white
}
int main(int argc, char** argv)
{
glutInit(&argc, argv); // still worked when this was commented out.. hmm..
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutInitWindowSize(600,600);
glutCreateWindow("not a rainbow but i can still pretend");
glutDisplayFunc(display);
glutMainLoop(); // no compiler errors when this was off but it just closed after a second
}
I realize it could have been done a lot.. better.. But I'm gonna call the beginner card on this one.
Here it is haha:
Poor rainbow. It's struggling |