perspective projection


I am trying to create perspective projection
I started with drawing a line with help from
the gluPerspective-command, but then I found out
that that is forbidden in this assignment

It’s like this:
*load a file with coords
*draw the figure with perspective projection
*use flat shading, painter’s algorithm etc

I am not sure whether or not to use gluOrtho2D
as replacement for gluPerspective or what to do.

Everything is to be made “by hand” …
For example how can make this line in display
visible ->

OG Regards

/********* GLUT callbacks ***********/
void display()
    /* Draw a grid on the screen */
    int x, y, w, h;

    w = glutGet(GLUT_WINDOW_WIDTH);
    h = glutGet(GLUT_WINDOW_HEIGHT);
    /* Clear the screen */
 //   glClear(GL_COLOR_BUFFER_BIT);
    /* Set color to light grey */
    glColor3f(0, 1.0, 0);


    glVertex3f(-2.0f, 2.0f, 0.0f);
    glVertex3f(2.0f, -2.0f, 0.0f);


    /* Force the commands to complete */


void idle()
    /* Update the GUI */
        /* The GUI window has been closed */

void reshape(int width, int height)
    /* Setup the viewport and transformations that must be used for
       the project */
    glViewport(0, 0, width, height);
    gluOrtho2D(0, width, height, 0);
 //gluPerspective(44.0f, width/height, 0.2f, 255.0f);
 //  gluOrth
    glTranslatef(0.0f, 0.0f, -128.0f); 

Don’t ask people on this forum to do your homework.
Read the OpenGL programming guide, search for redbook.pdf on the web.
Check Appendix F “Homogeneous Coordinates and Transformation Matrices”

I don’t want anyone to do my homework
I just want to know which part of the code
to work on to draw something in 3D in pp

OG regards

but then I found out that that is forbidden in this assignment
That sounded like homework.
gluPerspective calls glFrustum internally.
Look up the formulas in the cited programming guide and replace gluPerspective.
If that’s not what you’re asked for in the assignment, all you need should be explained in exactly that book.

Opengl uses three Pipelened matrix state. The first one is model view matrix, second is Projection matrix, third is Texture matrix. Programmer has options to load this 4X4 matrix contents. You have to load the appropiate values in the projection matrix. The details of the matrix contents is given in Principles of Computer Graphics using OPENGL by HILL