111/17/2015 03:24 uml solution involves selection of discrete representation values
TRANSCRIPT
104/20/23 18:06
UML
Solution Involves Selection of DiscreteRepresentation Values
204/20/23 18:06
UML
Antialiasing:An Example x 9
y 3
d0 2y x 3
incrE 2y 6
incrNE 2(y x) 12
304/20/23 18:06
UML
Aliasing:Square Pixels
404/20/23 18:06
UML
Antialiasing:Unweighted Area Sampling
Pixel Intensity Proportional toArea of Intersection
504/20/23 18:06
UML
Antialiasing:Unweighted Area Sampling
604/20/23 18:06
UML
Antialiasing:Weighted Sampling Function (Conical)
Desired Line
Weighting Function
Region of Overlap
704/20/23 18:06
UML
Gupta-Sproull Antialiasing
v
1+v
1-v
804/20/23 18:06
UML
Write from Memory to Frame Buffer
Main Memory
904/20/23 18:06
UML
Read from Frame Buffer into Main Memory
Main Memory
1004/20/23 18:06
UML
Copy from One Part of Frame Bufferto Another
1104/20/23 18:06
UML
OpenGL Functions for Reading, Writing,Copying Pixel Data
glReadPixels( ) - Reads a rectangular array of pixelsfrom the frame buffer and stores in main memory
glDrawPixels( ) - Writes a rectangular array of pixelsinto the frame buffer from data in main memory
glCopyPixels( ) - Copies a rectangular array of pixels fromone part of the frame buffer to another
Issues:
• Kind of frame buffer data• How data is stored in main memory• Data conversions performed during reading, writing, or copying
1204/20/23 18:06
UML
Reading Pixel DataFrame Buffer -> Memory
void glReadPixels(GLint x, Glint y, Glsizei width, GLsizei height, GLenum format,
Glenum type, GLvoid *pixels);
x - x coordinate of lower left corner of rectangular subimagey - y coordinate of lower left corner of rectangular subimagewidth - width of subimage in pixelsheight - height of subimage in pixelsformat - type of pixel data elements readtype - storage data type for each element*pixels - array to receive the data
1304/20/23 18:06
UML
Pixel Formats
GL_COLOR_INDEX A single color indexGL_RGB A red color component followed by
a green followed by a blue
GL_RGBA Red, green, blue, alpha componentsGL_RED A single red componentGL_GREEN A single green componentGL_BLUE A single blue componentGL_ALPHA A single alpha componentGL_LUMINANCE A single luminance component
GL_LUMINANCE_ALPHA A luminance component followedby an alpha component
GL_STENCIL_INDEX A single stencil indexGL_DEPTH_COMPONENT A single depth component
1404/20/23 18:06
UML
Data Types
GL_UNSIGNED_BYTE unsigned 8-bit integer
GL_BYTE signed 8-bit integer
GL_BITMAP single bits in unsigned8-bit integers
GL_UNSIGNED_SHORT unsigned 16-bit integer
GL_SHORT signed 16-bit integer
GL_UNSIGNED_INT unsigned 32-bit integer
GL_INT 32-bit integer
GL_FLOAT single-precision float pt.
1504/20/23 18:06
UML
Writing Pixel DataMemory -> Frame Buffer
void glDrawPixels(Glsizei width, GLsizei height, GLenum format,
Glenum type, GLvoid *pixels);
width - width of subimage in pixelsheight - height of subimage in pixelsformat - type of pixel data elements readtype - storage data type for each element*pixels - array holding the data to be drawn
Lower left corner of the subimage is defined by the currentraster position, defined by glRasterPos*().
1604/20/23 18:06
UML
Copying Pixel Data
void glCopyPixels(GLint x, Glint y, Glsizei width, GLsizei height,Glenum type);
x - x coordinate of lower left corner of rectangular subimagey - y coordinate of lower left corner of rectangular subimagewidth - width of subimage in pixelsheight - height of subimage in pixelstype - GL_COLOR, GL_DEPTH, or GL_STENCIL
Copied data is drawn at the current raster position.
1704/20/23 18:06
UML
Pixel Storage Mode Determination
void glPixelStore{if} (GLenum pname, TYPE param);
Parameter Type DefaultGL_UNPACK_SWAP_BYTES GLboolean FALSEGL_PACK_SWAP_BYTES
GL_UNPACK_LSB_FIRST GLboolear FALSEGL_PACK_LSB_FIRST
GL_UNPACK_ROW_LENGTH GLint 0GL_PACK_ROW_LENGTH
GL_UNPACK_SKIP_ROWS GLint 0GL_PACK_SKIP_ROWS
GL_UNPACK_SKIP_PIXELS GLint 0GL_PACK_SKIP_PIXELS
GL_UNPACK_ALIGNMENT GLint 4GL_PACK_ALIGNMENT
1804/20/23 18:06
UML
Reading a Subimage from Memory
ROW_LENGTH
subimage
SKIP_PIXELS
SKIP_ROWS
image in memory
1904/20/23 18:06
UML
Pixel Transfer Operations
void glPixelTransfer{if}(GLenum pname, TYPE param);
Parameter Type Default
GL_RED_SCALE GLfloat 1.0GL_GREEN_SCALE GLfloat 1.0GL_BLUE_SCALE GLfloat 1.0
GL_RED_BIAS GLfloat 0.0GL_GREEN_SCALE GLfloat 0.0GL_BLUE_SCALE GLfloat 0.0
... and many more
2004/20/23 18:06
UML
Graphics Files
Model Render Display
Model Render Display
Model Render Display
Store
Store
Customary graphics data flow:
Alternative graphics data flows:
2104/20/23 18:06
UML
Graphics File Types
“Vector” Bitmap
2204/20/23 18:06
UML
Vector File FormatsAdvantages and…….. Disadvantages
0 Efficient representation0 Work well for “line art”0 Well suited to scaling
(zoom)0 Objects can have identity0 Extensible to 3D
0 Limited set of objects that can be represented
2304/20/23 18:06
UML
Bitmap File FormatsAdvantages and…….. Disadvantages
0 Represent images with complex variations in colors
0 Storage size- Mitigated by
compression techniques0 Costly to manipulate0 Fixed resolution - problem
with scaling0 Inability to identify “objects”
2404/20/23 18:06
UML
Graphics MetafilesPage Description Languages
GraphicsMetafile
Attributes
Vector Data
Image Data
2504/20/23 18:06
UML
Bitmap File Formats:Generic Structure
Header
Pixel Data[Optional Compression]
[Color Table]
Fixed FileOffset
2604/20/23 18:06
UML
Example Bitmap Format:Windows BMP (Device Independent Bitmap)
File Header
Bitmap Data
Bitmap Header
0
14
2704/20/23 18:06
UML
Example Bitmap Format:Windows BMP (Device Independent Bitmap)
0
Offset Size Name Description
0 2 bfType ASCII “BM”
2 4 bfSize Size of file in bytes
6 2 bfReserved1 Zero
8 2 bfReserved2 Zero
10 4 bfOffBits Byte offset to image
File Header
2804/20/23 18:06
UML
Example Bitmap Format:Windows BMP (Device Independent Bitmap)
14Offset Size Name Description
14 4 biSize Size of this header
18 4 biWidth Image width (pixels)
22 4 biHeight Image height
26 2 biPlanes #planes (=1)
28 2 biBitCount Bits/pixel (1,4,8 or 24)
30 4 biCompression Compression type
34 4 biSizeImage Size (bytes) of comp.img.
38 4 biXPelsPerMeter x pixels/meter
42 4 biYPelsPerMeter y pixels/meter
46 4 biClrUsed Number of colors used
50 4 biClrImportant No. of important colors
54 4*N bmiColors Color Map
Bitmap Header
2904/20/23 18:06
UML
Example Bitmap Format:Windows BMP (Device Independent Bitmap)
54Offset Size Name Description
0 1 rgbBlue Blue value
1 1 rgbGreen Green value
2 1 rgbRed Red value
3 1 rgbReserved Zero
Color Map
3004/20/23 18:06
UML
Example Bitmap Format:Windows BMP (Device Independent Bitmap)
0 Bits are stored a row at a time starting from the bottom of the image to the top.
0 Each row is padded to a 4-byte boundary0 Significance of bits depends upon the number of bits per
pixel- In case of 1 bit per pixel each pixel is a single bit. High-
order bit is the leftmost pixel- In case of 4 bit per pixel images are packed two pixels per
byte, with the high nibble being the leftmost pixel
3104/20/23 18:06
UML
Example Bitmap Format:Windows BMP (Device Independent Bitmap)
Pixel 1
Pixel 2
Pixel 3
Pixel 4
Pixel 5
Pixel 6
Pixel 7
Pixel 8
Pixel 9
Pixel 10
Pixel 1
Pixel 2
8 bits/pixel (color index) 24 bits/pixel
Pixel 3
3204/20/23 18:06
UML
Windows BitmapRLE Compression
Repeating groups (2 bytes: count, repeated byte):
05 24 24 24 24 24 24
Literal groups (zero byte, pixel count, literal pixels):
00 05 12 34 56 78 9A 00 12 34 56 78 9A
Special group:
00 00 end of row00 01 end of bitmap00 02 xx yy continuation xx pixels to right and yy pixels down
3304/20/23 18:06
UML
Texture Mapping
Texture Map= image Polygon
3404/20/23 18:06
UML
Texture Mapping:The Main Steps
0 Specify the texture- Usually a single, two dimensional, rectangular image
=Can be one dimensional- Individual elements: texels- One to four elements per texel (RGBA)- OpenGL 1.x requires dimensions be powers of two
0 Define how the texture is to be applied to each pixel- Decal mode- Replace mode- Modulate mode- Blend mode- Add mode (new with OpenGL 2.0)
0 Enable texture mapping0 Draw the scene, supplying both texture and geometric coordinates
3504/20/23 18:06
UML
Texture Mapping:Specifying the Current Texture in OpenGL
void glTexImage2D(GLenum target, GLint level,GLint internalFormat,GLsizei width, GLsizei height, GLint border,GLenum format, GLenum type, GLvoid *texels);
target - future use, must be GL_TEXTURE_2D
level - 0 unless using multiple level of detail
internalFormat - one of 38 symbolic constants
width, height - height and width of texture map in texels
border - size of border in texels
format, type - storage parameters, same as glDrawPixels()
*texels - storage location of the texture map
3604/20/23 18:06
UML
Binding Texture Objects
void glBindTexture(GLenum target, GLuint textureName);
target: GL_TEXTURE_1D or GL_TEXTURE_2D
textureName: unique unsigned int identifier
When initially called, binds the default texture state to the identifier.Subsequent calls to texture functions modify the state of thetexture object.
When binding to a previously created texture object, that objectbecomes active.
Unique texture names can be generated by: glGenTextures()
3704/20/23 18:06
UML
Texture Mapping:Assigning Texture Coordinates
void glTexCoord2d(GLdouble s, GLdouble t);
s
t
1.00.00.0
1.0
Values outside [0.0, 1.0] can be made to either wrap orclamp to boundary values
Texture Image
3804/20/23 18:06
UML
Boundary Wrapping/Clamping
void glTexParameteri(GLenum target, GLenum pname,TYPE param);
target: GL_TEXTURE_2D
pname: GL_TEXTURE_WRAP_S or GL_TEXTURE_WRAP_T
param: GL_CLAMP uses the last pixel value in the s or tdirection for s,t outside [0,1]
GL_REPEAT repeats the texture pattern for s, t outside[0,1]
3904/20/23 18:06
UML
Texture Mapping:Magnification and Minification
Texture Polygon PolygonTexture
Magnification Minification
4004/20/23 18:06
UML
Texture Mapping:Specifying Filtering for Mag./Min.
glTexParameteri(GL_TEXTURE_2D, filter type, filter)’
filter type - GL_TEXTURE_MAG_FILTER for magnification, GL_TEXTURE_MIN_FILTER for minification
filter - GL_NEAREST selects the texel mapping nearest to the target pixel
GL_LINEAR performs a linear average of the 2x2 arrayof texels around the mapped point
4104/20/23 18:06
UML
Texture Mapping:How the Texture is Applied
void glTexEnv*(GLenum target, GLenum pname,GLenum param);
target - must be GL_TEXTURE_ENV
pname - GL_TEXTURE_ENV_MODE
param - one of GL_DECAL, GL_REPLACE,GL_MODULATE, GL_BLEND, GL_ADD
4204/20/23 18:06
UML
Texture Mapping:Interpreting glTexEnv() Parameters
From OpenGL 2.0 Specification, J. Leech & P. Brown, ed., Oct. 22, 2004
4304/20/23 18:06
UML
Texture Mapping:Interpreting glTexEnv() Parameters
From OpenGL 2.0 SpecificationFrom OpenGL 2.0 Specification, J. Leech & P. Brown, ed., Oct. 22, 2004