Solution Involves Selection of Discrete Representation Values - PowerPoint PPT Presentation

1 / 43
About This Presentation
Title:

Solution Involves Selection of Discrete Representation Values

Description:

Read from Frame Buffer into Main Memory. Main Memory. 10. UML. Copy from One Part of ... From OpenGL 2.0 Specification, J. Leech & P. Brown, ed., Oct. 22, 2004 ... – PowerPoint PPT presentation

Number of Views:49
Avg rating:3.0/5.0
Slides: 44
Provided by: HughMas6
Category:

less

Transcript and Presenter's Notes

Title: Solution Involves Selection of Discrete Representation Values


1
Solution Involves Selection of DiscreteRepresenta
tion Values
2
AntialiasingAn Example
3
AliasingSquare Pixels
4
AntialiasingUnweighted Area Sampling
Pixel Intensity Proportional to Area of
Intersection
5
AntialiasingUnweighted Area Sampling
6
AntialiasingWeighted Sampling Function (Conical)
Weighting Function
Desired Line
Region of Overlap
7
Gupta-Sproull Antialiasing
1-v
v
1v
8
Write from Memory to Frame Buffer
Main Memory
9
Read from Frame Buffer into Main Memory
Main Memory
10
Copy from One Part of Frame Bufferto Another
11
OpenGL Functions for Reading, Writing,Copying
Pixel Data
  • glReadPixels( ) - Reads a rectangular array of
    pixels
  • from the frame buffer and stores in main memory
  • glDrawPixels( ) - Writes a rectangular array of
    pixels
  • into the frame buffer from data in main memory
  • glCopyPixels( ) - Copies a rectangular array of
    pixels from
  • one 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

12
Reading Pixel DataFrame Buffer -gt 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
subimage y - y coordinate of lower left corner of
rectangular subimage width - width of subimage in
pixels height - height of subimage in
pixels format - type of pixel data elements
read type - storage data type for each
element pixels - array to receive the data
13
Pixel Formats
GL_COLOR_INDEX A single color index GL_RGB A
red color component followed by a green
followed by a blue GL_RGBA Red, green, blue,
alpha components GL_RED A single red
component GL_GREEN A single green
component GL_BLUE A single blue
component GL_ALPHA A single alpha
component GL_LUMINANCE A single luminance
component GL_LUMINANCE_ALPHA A luminance
component followed by an alpha
component GL_STENCIL_INDEX A single stencil
index GL_DEPTH_COMPONENT A single depth component
14
Data Types
GL_UNSIGNED_BYTE unsigned 8-bit
integer GL_BYTE signed 8-bit
integer GL_BITMAP single bits in
unsigned 8-bit integers GL_UNSIGNED_SHORT un
signed 16-bit integer GL_SHORT signed 16-bit
integer GL_UNSIGNED_INT unsigned 32-bit
integer GL_INT 32-bit integer GL_FLOAT singl
e-precision float pt.
15
Writing Pixel DataMemory -gt Frame Buffer
void glDrawPixels(Glsizei width,
GLsizei height, GLenum format, Glenum type,
GLvoid pixels) width - width of subimage in
pixels height - height of subimage in
pixels format - type of pixel data elements
read type - storage data type for each
element pixels - array holding the data to be
drawn Lower left corner of the subimage is
defined by the current raster position, defined
by glRasterPos().
16
Copying Pixel Data
void glCopyPixels(GLint x, Glint y, Glsizei
width, GLsizei height,Glenum
type) x - x coordinate of lower left corner of
rectangular subimage y - y coordinate of lower
left corner of rectangular subimage width - width
of subimage in pixels height - height of subimage
in pixels type - GL_COLOR, GL_DEPTH, or
GL_STENCIL Copied data is drawn at the current
raster position.
17
Pixel Storage Mode Determination
void glPixelStoreif (GLenum pname, TYPE
param) Parameter Type Default GL_UNPACK_SWAP_
BYTES GLboolean FALSE GL_PACK_SWAP_BYTES GL_UNPAC
K_LSB_FIRST GLboolear FALSE GL_PACK_LSB_FIRST GL_
UNPACK_ROW_LENGTH GLint 0 GL_PACK_ROW_LENGTH GL_
UNPACK_SKIP_ROWS GLint 0 GL_PACK_SKIP_ROWS GL_UN
PACK_SKIP_PIXELS GLint 0 GL_PACK_SKIP_PIXELS GL_
UNPACK_ALIGNMENT GLint 4 GL_PACK_ALIGNMENT
18
Reading a Subimage from Memory
ROW_LENGTH
subimage
SKIP_PIXELS
SKIP_ROWS
image in memory
19
Pixel Transfer Operations
void glPixelTransferif(GLenum pname, TYPE
param) Parameter Type Default GL_RED_SCALE
GLfloat 1.0 GL_GREEN_SCALE GLfloat 1.0 GL_BLUE
_SCALE GLfloat 1.0 GL_RED_BIAS GLfloat 0.0 G
L_GREEN_SCALE GLfloat 0.0 GL_BLUE_SCALE GLfloat
0.0 ... and many more
20
Graphics Files
Customary graphics data flow
Alternative graphics data flows
Model
Render
Store
Display
Store
Model
Render
Display
21
Graphics File Types
Vector
Bitmap
22
Vector File FormatsAdvantages and..
Disadvantages
  • Efficient representation
  • Work well for line art
  • Well suited to scaling (zoom)
  • Objects can have identity
  • Extensible to 3D
  • Limited set of objects that can be represented

23
Bitmap File FormatsAdvantages and..
Disadvantages
  • Represent images with complex variations in
    colors
  • Storage size
  • Mitigated by compression techniques
  • Costly to manipulate
  • Fixed resolution - problem with scaling
  • Inability to identify objects

24
Graphics MetafilesPage Description Languages
Vector Data
Graphics Metafile
Attributes
Image Data
25
Bitmap File FormatsGeneric Structure
Header
Fixed File Offset
Color Table
Pixel Data Optional Compression
26
Example Bitmap FormatWindows BMP (Device
Independent Bitmap)
0
File Header
14
Bitmap Header
Bitmap Data
27
Example Bitmap FormatWindows BMP (Device
Independent Bitmap)
File Header
0
Offset Size Name
Description 0 2 bfType ASCII BM 2 4 bfSize Size
of file in bytes 6 2 bfReserved1 Zero 8 2 bfReserv
ed2 Zero 10 4 bfOffBits Byte offset to image
28
Example Bitmap FormatWindows BMP (Device
Independent Bitmap)
14
Offset 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 4N bmiColors Color Map
Bitmap Header
29
Example Bitmap FormatWindows BMP (Device
Independent Bitmap)
54
Offset Size Name
Description 0 1 rgbBlue Blue value 1 1 rgbGreen Gr
een value 2 1 rgbRed Red value 3 1 rgbReserved Zer
o
Color Map
30
Example Bitmap FormatWindows BMP (Device
Independent Bitmap)
  • Bits are stored a row at a time starting from the
    bottom of the image to the top.
  • Each row is padded to a 4-byte boundary
  • 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

31
Example Bitmap FormatWindows BMP (Device
Independent Bitmap)
8 bits/pixel (color index)
24 bits/pixel
Pixel 1
Pixel 1
Pixel 2
Pixel 3
Pixel 4
Pixel 2
Pixel 5
Pixel 6
Pixel 7
Pixel 3
Pixel 8
Pixel 9
Pixel 10
32
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 row 00
01 end of bitmap 00 02 xx yy continuation xx
pixels to right and yy pixels down
33
Texture Mapping
Texture Map image
Polygon
34
Texture MappingThe Main Steps
  • 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
  • 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)
  • Enable texture mapping
  • Draw the scene, supplying both texture and
    geometric coordinates

35
Texture MappingSpecifying 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() texel
s - storage location of the texture map
36
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. Subsequen
t calls to texture functions modify the state of
the texture object. When binding to a
previously created texture object, that
object becomes active. Unique texture names can
be generated by glGenTextures()
37
Texture MappingAssigning Texture Coordinates
void glTexCoord2d(GLdouble s, GLdouble t)
t
1.0
Texture Image
s
0.0
1.0
0.0
Values outside 0.0, 1.0 can be made to either
wrap or clamp to boundary values
38
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 t direction for s,t
outside 0,1 GL_REPEAT repeats the texture
pattern for s, t outside 0,1
39
Texture MappingMagnification and Minification
Texture
Polygon
Polygon
Texture
Magnification
Minification
40
Texture MappingSpecifying 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 array of texels around the mapped
point
41
Texture MappingHow 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
42
Texture MappingInterpreting glTexEnv()
Parameters
From OpenGL 2.0 Specification, J. Leech P.
Brown, ed., Oct. 22, 2004
43
Texture MappingInterpreting glTexEnv()
Parameters
From OpenGL 2.0 Specification
From OpenGL 2.0 Specification, J. Leech P.
Brown, ed., Oct. 22, 2004
Write a Comment
User Comments (0)
About PowerShow.com