Utilizing Representation Libraries.

Uploaded on:
Category: News / Events
Utilizing Design Libraries Address 3 Mon, Sep 1, 2003 Illustrations Libraries Hypothetically, with just a capacity setPixel(x, y, red, green, blue), we could make any representation picture. In any case, it would be very repetitive.
Slide 1

Utilizing Graphics Libraries Lecture 3 Mon, Sep 1, 2003

Slide 2

Graphics Libraries Theoretically, with just a capacity setPixel(x, y, red, green, blue), we could make any illustrations picture. On the other hand, it would be entirely repetitive. A design library gives a wealth of helpful capacities to rearrange the assignment of making representation.

Slide 3

Device Independence A library is gadget autonomous on the off chance that it gives a typical API, paying little respect to the equipment on which it is utilized. The OpenGL API for Windows is indistinguishable to the OpenGL API for the Macintosh. Obviously, the library must be incorporated independently for every equipment framework.

Slide 4

Windows-Based Programming OpenGL comprises of three libraries gl – illustrations library Basic capacities. glu – illustrations library utility Composites of fundamental GL capacities. excess – design library utility toolbox Functions that collaborate with the windowing framework.

Slide 5

Window-based Programming int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(screenWidth, screenHeight); glutInitWindowPosition(100, 150); glutCreateWindow(“My Window Title"); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutMouseFunc(mouse); init(); glutMainLoop(); return 0; }

Slide 6

Window-Based Programming The overabundance capacities are utilized as a part of primary() to make and open a representation window. Capacities used to make an illustrations window. glutInit(&argc, argv). glutInitDisplayWindow(options). glutInitWindowSize(width, tallness). glutInitWindowPosition(x, y). glutCreateWindow(name).

Slide 7

Windows-Based Programming glutInit (&argc, argv). Instates the overabundance library. Should be called before some other overabundance capacity. Must get the order line contentions. glutInitDisplayMode (choices). Indicates shading mode. Determines single or twofold buffering.

Slide 8

Windows-Based Programming glutInitWindowSize (width, tallness). Sets the tallness and width of the window in pixels. glutInitWindowPosition (x, y). Sets the upper\'s position left corner of the window. glutCreateWindow (name). Makes, yet does not show, the window.

Slide 9

Callback Functions A callback capacity is a client determined capacity that the library will call at whatever point important. Every callback capacity must be enlisted with excess. excess accommodates more than 20 callbacks .

Slide 10

Callback Functions The excess library contains capacities with names of the structure glutXXXFunc(parameter), where XXX stands for some type of windows communication (mouse, console, and so on.). The parameter is a client characterized capacity xxx().

Slide 11

Callback Functions In the fundamental capacity we compose glutXXXFunc(xxx). At that point when XXX is initiated by the client (mouse click, keystroke, and so on.), the capacity xxx() is called to handle the occasion.

Slide 12

OpenGL Callback Functions glutDisplayFunc (showcase); Called at whatever point the scene should be redrawn. Actuated by calls to glutPostRedisplay(). glutReshapeFunc (reshape); Called at whatever point the window is resized. Initiated by resizing the window. Cautioning: This does not react to iconifying the window.

Slide 13

OpenGL Callback Functions glutMouseFunc (mouse) Called at whatever point the mouse is clicked. Actuated by mouse clicks. Left or right, up or down. glutKeyboardFunc (console) Called at whatever point a key is squeezed. Enacted by keystrokes (down just) of an ASCII key (letters, digits, accentuation).

Slide 14

OpenGL Callback Functions glutSpecialFunc (unique) Called at whatever point an extraordinary key is squeezed. Enacted by keystrokes (down just) of a non-ASCII key (capacity key, bolt key, and so forth.). glutMotionFunc (movement) Called at whatever point the mouse is moved while the catch is squeezed.

Slide 15

OpenGL Callback Functions glutPassiveMotionFunc (passiveMotion) Called at whatever point the mouse is moved while the catch is not squeezed. glutIdleFunc (unmoving) Called at whatever point nothing else is going on.

Slide 16

The Main Loop Typically primary() closes by calling glutMainLoop() This capacity runs until the end of time. It calls the callback capacities as important. It handles every single drawing summon as they are created.

Slide 17

glutMainLoop() fundamental presentation() showcase Process console and mouse occasions reshape() reshape console() console mouse() mouse The Main Loop Library Functions

Slide 18

Example: Callback Functions CallbackTest.cpp

Slide 19

Other Initializations void init() { glClearColor(0.8, 0.8, 0.8, 0.0);/light dark glColor3f(0.0f, 0.0f, 0.0f);/dark glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(xmin, xmax, ymin, ymax); glViewport(0, 0, screenWidth, screenHeight); }

Slide 20

World Coordinates The call to gluOrtho2D() builds up the world directions of the window. gluOrtho2D( xmin , xmax , ymin , ymax ) The x-directions go from xmin to xmax from left to right . The y-directions go from ymin to ymax from base to beat .

Slide 21

Example: Draw a 2D Object DrawTeapot.cpp

Slide 22


View more...