'How to change Camera Angle FreeGLUT

I drew a rectangle in the X-Z play of a 3D, XYZ, plane using the code below.

#include <GL/glut.h>

void drawPlane() {
    GLfloat A[3] = { 0,  0, 0};
    GLfloat B[3] = { 1,  0, 0};
    GLfloat C[3] = { 1,  0, 1};
    GLfloat D[3] = { 0,  0, 1};

    glBegin(GL_POLYGON);
        glVertex3fv(A);
        glVertex3fv(B);
        glVertex3fv(C);
        glVertex3fv(D);
    glEnd();
}

// Display Call Back
void draw(){
    glLoadIdentity();
    glTranslatef(0.0, 0.5, 1); //i thought this would do the camera thing
    drawPlane();
    glutSwapBuffers();// Render Now
    return;
}

// Initialization
void initialize()
{
    glClearColor(0.1f, 0.1f, 0.1f, 0.1f); // Set Background Color
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear all drawings in buffer
}


// Main
int main(int argc, char* argv[])
{
    glutInit(&argc, argv); // Initialize GLUT
    int x = 512, y = 512;  // x and y value
    glutInitWindowPosition(
        (int)(glutGet(GLUT_SCREEN_WIDTH) - x) / 2,
        (int)(glutGet(GLUT_SCREEN_HEIGHT) - y) / 2);              // Position the window's center
    glutInitWindowSize(x, y);                                     // Set the window's initial width & height
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);     // ESSENTIAL BUT HAVE NO IDEA WHAT THIS DOES
    glutCreateWindow("3d Bowling Game");                          // Create a window with the given title
    glutDisplayFunc(draw);                                        // Register display callback handler for window re-paint
    glutMainLoop();                                               // Enter the event-processing loop
    initialize();
    return 0;
}

How do I change the camera angle in order to view all of the coordinates like below.

what i would love



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source