1 / 11

Project 1: Into Space! CG Concepts Needed

Project 1: Into Space! CG Concepts Needed. Introduction to Computer Graphics CSE 470 Arizona State University Dianne Hansford. What you’ll find here …. Transformation order in OGL Viewports Object WorldViewportWindow Bitmapped Fonts Display lists Push/Pop Attributes.

moana
Download Presentation

Project 1: Into Space! CG Concepts Needed

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. Project 1: Into Space!CG Concepts Needed Introduction to Computer GraphicsCSE 470Arizona State University Dianne Hansford

  2. What you’ll find here … • Transformation order in OGL • Viewports • ObjectWorldViewportWindow • Bitmapped Fonts • Display lists • Push/Pop Attributes

  3. Transformations in OGL Given: a unit square centered at the origin Write: OGL code that 1) translates by one unit in x, and then2) rotates by 90 degrees Solution:glRotatef(90.0, 0.0, 0.0, 1.0);glTranslatef(1.0, 0.0, 0.0);drawsquare();glFlush(); The point: specify OGL commands in opposite order of occurance. In matrix notation: v’ = I R T v RedBook: see Ch 3 Modeling sections we’ll discuss how T getsin a matrix later!

  4. Viewports Defines a rectangular region in window for drawingExample: Powerpoint slide edit viewport, slide layout viewport, slides overview viewport.Example: Spacecraft control viewport and space viewport window viewports

  5. Viewports glViewport(x, y, width, height) Parameters in terms of pixels Keep in mind that the windowing system returns [x,y] relative to the origin at the upper-left corner, but the viewport is defined relative to the origin at the lower-left corner. height x y width -- when ready to draw, set the appropriate viewport -- aspect ratio of viewport = aspect ratio of ortho2D -- when window resized, must resize viewport

  6. Coordinate Systems Object  World  Viewport  Window Input geometry:e.g. star verticescreated at origin space orspacecraftscene portion of windowyou’ll draw to input geometry should be transformed (translate, rotate, scale)to live in your world window to viewport to world transformation needed

  7. Bitmapped Fonts set positionglRasterPos2f(x, y); (in world coordinates) create characterglutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_10, ‘H’); you can find more fonts in glut.h Next: Display lists are a good way to use fonts. For 2D bitmapped fonts ok. For 3D stroke fonts might be better – can scale and rotate

  8. Display Lists Rendering modes: immediate and retained immediate: -- what we have been doing -- primitives down pipeline then no longer in system (on screen) -- primitives generated with each redraw -- can be slow for complex scene or in client/server environment retained: -- primitives and states stored as an object in a display list -- internal format makes them fast for display; cached -- good for redrawing geometry multiple times -- good for fast redraw of a complex object/scene

  9. Display Lists Define a single display list:#define SQUAREglNewList(SQUARE, GL_COMPILE); glPushAttrib(GL_CURRENT_BIT); glColor3f(1, 0, 0); glRectf(0, 0, 1, 1); glPopAttrib();glEndList(); Draw this display listglCallList(SQUARE); see next topic:Attributes forming of display list called compiling it RedBook: See Ch 7

  10. Multiple Display Lists When working with many display listsfor example: text the multiple list utilities are nice find the starting point for 256 consecutive,free integers for DL font_base = glGenLists(256); for(i=0; i < 256; i++) { glNewList(base + i, GL_COMPILE); glutBitMapCharacter(GLUT_BITMAP…., i); glEndList(); } … char *text; glListBase(font_base); glCallLists( (GLint) strlen(text), GL_UNSIGNED_BYTE, text); start accessing DL from base

  11. Attribute Groups State variables are groupedsee chapter 2 “Attribute Groups” for a listExample: all line characteristics (width, stipple, pattern, …) in GL_LINE_BIT Example from display list slide: glPushAttrib(GL_CURRENT_BIT);glColor3f(1, 0, 0);glRectf(0, 0, 1, 1); glPopAttrib(); > save current state> change the color and draw> restore the state as it was

More Related