I just started trying to learn OpenGL, and I cant get a simple program to work. I can open a window using GLUT, but when I tried to make a colored pyramid, i could only see the nearest corner of it. I have been reading for hours, and looking at other peoples code, but I cant figure out whats wrong with mine.
#include <GL/glut.h>
#include <GL/gl.h>
#include <unistd.h>
void myDisplayFunction(void);
int main(int argc, char **argv){
glutInit(&argc, argv);
glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(700,500);
glutCreateWindow(“First OpenGL Program”);
glClearColor(0,0,0,0);
glutDisplayFunc(&myDisplayFunction);
glutIdleFunc(&myDisplayFunction);
glutMainLoop();
}
void myDisplayFunction(void){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0,-.5,.5);
glRotatef(-15,1,0,0);
glBegin(GL_TRIANGLES);
glColor3f(1,0,0);
glVertex3f(0,1,1);
glColor3f(0,1,0);
glVertex3f(1,0,2);
glColor3f(0,0,1);
glVertex3f(-1,0,2);
glColor3f(0,0,1);
glVertex3f(-1,0,2);
glColor3f(0,1,0);
glVertex3f(1,0,2);
glColor3f(1,0,1);
glVertex3f(0,0,0);
glColor3f(1,0,0);
glVertex3f(0,1,1);
glColor3f(0,0,1);
glVertex3f(-1,0,2);
glColor3f(1,0,1);
glVertex3f(0,0,0);
glColor3f(1,0,0);
glVertex3f(0,1,1);
glColor3f(0,1,0);
glVertex3f(1,0,2);
glColor3f(1,0,1);
glVertex3f(0,0,0);
glutSwapBuffers();
}