260 likes | 356 Views
Computer Graphics OpenGL Continued. C o m p u t e r G r a p h i c s. OpenGL state settings :. Many characteristics of graphical objects can be affected by the setting of various state variables in OpenGL. Color of objects to be drawn is one example: glColor3f(1.0, 0, 1.0);.
E N D
Computer GraphicsOpenGL Continued... Computer Graphics
OpenGL state settings: Many characteristics of graphical objects can be affected by the setting of various state variables in OpenGL Color of objects to be drawn is one example: glColor3f(1.0, 0, 1.0); glColor3ub(255,0,255);
s Stroke text - vertices, line segments and curves used to outline each character. Easily scaled. Raster text - each character is basically a small image (pixels). Rapidly rendered by bit-block-transfer (BITBLT) into the frame buffer. Text as primitive objects : • There are two forms of text in graphics: • Stroke • Raster
Drawing text in OpenGL : OpenGL does not provide a text drawing primitive since stroke and raster characters can be created from other primitives GLUT provides a few stroke and raster character sets. glutBitmapCharacter (GLUT_BITMAP_8_BY_13, 'c'); glutStrokeCharacter (GLUT_STROKE_MONO_ROMAN, 'c');
OpenGL object attributes: An attribute is a property that determines how a primitive will be displayed Point: color, size Line: color, thickness and type Polygons: attributes to specify filling
OpenGL:color RGB system is a three color ADDITIVE COLOR MODEL each color is specified in terms of Red, Green, and Blue intensities
BLUE (0,0,1) CYAN (0,1,1) MAGENTA (1,0,1) GREEN (0,1,0) RED (1,0,0) YELLOW (1,1,0) RGB color model
OpenGL:color RGB system is a three color ADDITIVE COLOR MODEL each color is specified in terms of Red, Green, and Blue intensities glColor3f(R,G,B); // where R, G, & B are in the range [0.0..1.0] we can use 4 parameters R,G,B,A glColor4f(R,G,B,A); where A=0.0 is transparent and A=1.0 is opaque
OpenGL:color glClearColor(1.0, 1.0, 1.0 ,1.0); // defines the clearing color (R,G,B) as // opaque white glClear(); // then clears the window
- Use a table of RGB values indexed by a k-bit number allows 2 colors - This is called a color-lookup table k OpenGL:indexed color
0 0 0 255 255 0 0 0 0 128 255 0 255 128 0 ... 0 0 0 255 0 0 0 255 255 0 255 255 0 0 0 0 0 255 0 0 0 128 255 255 OpenGL:indexed color index color 0 1 2 3 4 5 6 7 8 9 10 11 ... 255
Creation of a 3D View Mapping a 3D view onto a 2D screen requires: • specifying a projection model • specifying viewing parameters • 3d clipping • projection and display
3D Projection “defined by straight projection of rays emanating from a center of projection (COP), passing through each point in the object and intersecting the projection plane.”
Planar Geometric Projection Perspective - has a finite COP Parallel - has an infinite COP
Planar Geometric Projection Perspective - has a finite COP
Planar Geometric Projection Perspective : - has a finite COP - foreshortening yields more realistic images - less suitable for measurement of exact shape and relative size
Planar Geometric Projection Parallel - has an infinite COP
Planar Geometric Projection Parallel : - has an infinite COP, sometimes referred to by DOP (direction of projection) - yields less realistic images - more suitable for measurement of exact shape and relative size
Parallel Projection Orthographic - projection plane is parallel to a principal face of the object Axonometric - projectors are normal to the projection plane but can have any orientation with respect to the object Oblique - the projectors form any angle with the viewing plane
Parallel Projection Orthographic - projection plane is parallel to a principal face of the object
Parallel Projection Orthographic - projection plane is parallel to a principal face of the object FRONT TOP SIDE
Perspective Projection One point Two point Three point Depends upon how many of the principal faces of the object are parallel to the viewing plane
Perspective Projection One point
Perspective Projection Two point
Perspective Projection Three point