Question: /* * hello.c * This is a simple, introductory OpenGL program. */ #include #include #include #include void display(void) { /* clear all pixels */ glClear

 /* * hello.c * This is a simple, introductory OpenGL program.

/* * hello.c * This is a simple, introductory OpenGL program. */ #include

#include #include #include

void display(void) { /* clear all pixels */ glClear (GL_COLOR_BUFFER_BIT);

/* draw white polygon (rectangle) with corners at * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0) */ glColor3f (255.0, 0.0, 0.0); glBegin(GL_POLYGON); glVertex3f (0.25, 0.25, 0.0); glVertex3f (0.75, 0.25, 0.0); glVertex3f (0.75, 0.75, 0.0); glVertex3f (0.25, 0.75, 0.0); glEnd();

/* don't wait! * start processing buffered OpenGL routines */ glFlush (); }

void init (void) { /* select clearing color */ glClearColor (0.0, 0.0, 0.0, 0.0);

/* initialize viewing values */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); }

/* * Declare initial window size, position, and display mode * (single buffer and RGBA). Open window with "hello" * in its title bar. Call initialization routines. * Register callback function to display graphics. * Enter main loop and process events. */ int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (250, 250); glutInitWindowPosition (100, 100); glutCreateWindow ("hello"); init (); glutDisplayFunc(display); glutMainLoop(); return 0; /* We'll never be here.*/ }

a1.pdf 2 of 2 A' Read aloud Draw Highlight v Erase (3) (8 marks) In program hello.c posted on the course website, find the similar lines of code as follows and try to understand them. Now use the following lines of code to answer some questions. glutinitWindowSize (600, 400); glOrtho(0.0, 2.0, 0.0, 2.0,-1.0, 1.0); glVertex3f (0.25, 0.25, 0.0); // V1 glVertex3f (0.75, 0.25, 0.0); // 12 (a) (2 marks) What does function glOrtho do? (b) (3 marks) Calculate the distance between the two points V, and V2, in the unit of pixels, on the monitor. (c) (3 marks) There is some abnormal situation that happens in terms of the parameters used in setting up the window, viewport, etc. Explain what the situation is and explain why it happens. Assignment 1 Part (B) (To be announced shortly) (10 marks) Due: February 5 (Friday), 11:55pm on Moodle Type here to search lara ENG 9:28 AM 2021-01-26 a1.pdf 2 of 2 A' Read aloud Draw Highlight v Erase (3) (8 marks) In program hello.c posted on the course website, find the similar lines of code as follows and try to understand them. Now use the following lines of code to answer some questions. glutinitWindowSize (600, 400); glOrtho(0.0, 2.0, 0.0, 2.0,-1.0, 1.0); glVertex3f (0.25, 0.25, 0.0); // V1 glVertex3f (0.75, 0.25, 0.0); // 12 (a) (2 marks) What does function glOrtho do? (b) (3 marks) Calculate the distance between the two points V, and V2, in the unit of pixels, on the monitor. (c) (3 marks) There is some abnormal situation that happens in terms of the parameters used in setting up the window, viewport, etc. Explain what the situation is and explain why it happens. Assignment 1 Part (B) (To be announced shortly) (10 marks) Due: February 5 (Friday), 11:55pm on Moodle Type here to search lara ENG 9:28 AM 2021-01-26

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!