YoungMinKim/Assignment 1에 대해 써주세요.
1. In a GLUT program, how is control passed back to the programmer? How is this set up during initialization?
A typical OpenGL program ends in a infinite loop -glutMainLoop(). However, the program can interact with user via callback functions that a programmer writes. Callback functions are invoked whenever discrete events happen, such as mouse events, keyboard events, window events. The events are then pushed into event queue and for each event, the corresponding callback functions, defined by user, are called. For example, if you want to call function key whenever any key on keyboard is hit, you can write glutKeyboardFunc(key) before the line glutMainLoop(). The setup for callback functions has to be made during initialization because the parts after glutMainLoop() cannot be processed by computer.
2. What does the parameter to glutInitDisplayMode() in main() specify?
glutInitDisplayMode is a function that specifies the characteritics of the display window. GLUT_RGBA means that you are using RGBA color mode. GLUT_DOUBLE specifies that you are using double-buffered window instead of single-buffered one. You can set distinct modes of display by ORing them.
3. What do the calls to glOrtho() and glViewport() in the reshape() function accomplish? If the window is to be resized, why might we want to change this?
glOrtho specifies the orthogonal coordinate system you are using. The each parameter means left, right, bottom, top, near, far coordinates, respectively. glViewport() is called to sets the position and size of viewport in the window. viewportis a rectangular area of the window on the screen that restrict OpenGL to draw on. Whenever the window is resized, these functions are called to reset the coordinate system and drawing space adapted to the new window.