1 / 14

CS770/870

CS770/870. Class 2. Assignment 1. Simple video game. Paddle. Glut. Graphics library utility toolkit. Provides windows, simple menus. (and removes the need for a lot of ugly code). GlutCB Mouse. GlutCB Keyboard. GlutCB Menus. OS. Main Setup callbacks Glut Hand control to OS.

melosa
Télécharger la présentation

CS770/870

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS770/870 Class 2

  2. Assignment 1 Simple video game Paddle

  3. Glut Graphics library utility toolkit. Provides windows, simple menus. (and removes the need for a lot of ugly code)

  4. GlutCB Mouse GlutCB Keyboard GlutCB Menus OS Main Setup callbacks Glut Hand control to OS

  5. The opengl pipeline (again) Double buffering Graphics App Transform Translate Rotate scale Project Clip Rasterize What? -- mostly polygons BackBuffer Blocking Front Buffer

  6. More glut glutSwapBuffers() – blocks the main program – holds program to a 60 Hz update rate glutDisplayFunc() glutIdleFunc() – always good for smooth animation glutMotionFunc() Demo all.

  7. Drawing in OpenGL Graphics Primitives • glBegin( <feature type> ); • GL_LINES, GL_TRIANGLES, GL_POINTS, GL_TRIANGLE_STRIP • GL_QUAD_STRIP, GL_TRIANGLE_FAN • glColor(); • glVertex(); • glEnd(); • Note there are also pixel-based operations that Bypass the frame buffer. • Show an example using openGL first a simple triangle.

  8. A circle, and a Sphere Circle class exercise. Use triangle Fan. Sphere review code.

  9. Simple Animation for A1 x = x + dx; y = y + dy; Bouncing off walls Gravity Must deal with contacts with paddle Steering the ball – increasing speed Must deal with contact with targets. Try to make a reasonable level of difficulty

  10. Animation, motion, gravity Motion is the change in position with time (dx, dy); Acceleration is the second derivative of velocity in a vertical direction. Dy = dy – 0.01 Reflection on walls easy – not so easy for an oblique line. One method reflect and rotate.

  11. Viewports (if time) Like windows within windows glViewPort(x,y, w, h) Viewports are defined in terms of pixels. By default the viewport is the same as the glut window (it can be larger, it can be smaller). The Viewport The scene can be mapped into the viewport using glOrtho(Sleft,Sright, Stop, Sbot, Snear, Sfar); The parameters are in scene coordinate.

  12. Scene window to viewport mapping Like a window in the word Scene window to viewport mapping viewport scene

  13. Dealing with aspect ratios Three choices Let things distort but still fill the screen (default) Keep everything the same in terms of on screen sizes Keep scene window at a constant area with no distortion

  14. Dealing with aspect ratios Original window area { float scale; winWid = w; winHeight = h; scale = sqrt(winArea/(winWid*winHeight)); glViewport(0,0,w,h); // a sub area of the glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Define the scene window to viewport mapping glOrtho(0.0,winWid*scale,0.0,winHeight*scale, -100.0, 100.0); glMatrixMode(GL_MODELVIEW); }

More Related