Im just starting to learn OpenGL. I’m wondering if someone here could help me with a piece of code…
#include <gl/glut.h>
void drawStar() {
glBegin(GL_TRIANGLES);
glVertex2f(-0.5, -0.5);
glVertex2f(0.5, -0.5);
glVertex2f(0.0, 0.5);
glVertex2f(-0.5, 0.15);
glVertex2f(0.5, 0.15);
glVertex2f(0.0, -0.85);
glEnd();
}
void display(void) {
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluOrtho2D(-1, 1, -1, 1);
drawStar();
glFlush ();
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutCreateWindow (“Star”);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
How do you modify the display() function so that a 3-dimensional projection is used rather than an orthographic projection? Do you use gluPerspective(fov,aspect, near, far)?Its probably simple enough to solve but I just dont really have a clue what to do! Any help would be very much appreciated!