#include <stdio.h>
#include <stdlib.h>
#include <GL/gl.h>
#include <GL/glut.h>
#define KEY_ESCAPE 27
void display();
void keyboard(unsigned char,int,int);
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitWindowSize(600,400);
glutCreateWindow("Opengl Test");
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH );
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
void display() {
int i;
float x,y,z;
x=0;
y=0;
z=0;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport(0,0,300,400);
glBegin(GL_POINTS);
for(i=0;i<50;i++) {
glColor3f(1,0,1);
glVertex3f(x,y,z);
x=x+0.02;
}
glEnd();
glutSwapBuffers();
}
void keyboard(unsigned char key, int x, int y) {
switch (key) {
case 27:
exit (0);
break;
}
}
I want to set color to viewport. How can i do this?