Activity 1 |
Modified: |
Basic OpenGL
Rearrange the following as a working OpenGL program.
- int main(int argc, char** argv)
- #include <GL/glut.h>
- glutDisplayFunc(mydisplay);
- glEnd();
- void mydisplay()
- glColor3f(1.0,1.0,1.0);
- glVertex3f(0.5,0.5,-3.0);
- glClear(GL_COLOR_BUFFER_BIT);
- glBegin(GL_LINES);
- glFlush();
- glutMainLoop();
- glutCreateWindow("simple");
- glVertex3f(-0.5,-0.5,-1.0);
Is the line visible now?
Enter in Visual Studio and test.
Viewing volume
Where should the following be added to change the viewing volume?
glOrtho(-1.0, 1.0, -1.0, 1.0, -2.0, 2.0);
glLoadIdentity ();
glMatrixMode (GL_PROJECTION);Is the line visible now?
Enter in Visual Studio and test.
Mouse events
Change the program to place dots whenever the right mouse button is clicked (see page 117).
State of program
What changes are necessary to connect the dots with lines.
Make the changes and test.