12
CMPE 466 COMPUTER GRAPHICS Chapter 5 Attributes of Graphics Primitives Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ® , Fourth Edition by Donald Hearn, M. Pauline Baker, and Warren R. Carithers - Fundamentals of Computer Graphics, Third Edition by by Peter Shirley and Steve Marschner 1

CMPE 466 COMPUTER GRAPHICS Chapter 5 Attributes of Graphics Primitives Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth

Embed Size (px)

Citation preview

Page 1: CMPE 466 COMPUTER GRAPHICS Chapter 5 Attributes of Graphics Primitives Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth

1

CMPE 466COMPUTER GRAPHICSChapter 5

Attributes of Graphics Primitives

Instructor: D. Arifler

Material based on- Computer Graphics with OpenGL®, Fourth Edition by Donald Hearn, M. Pauline Baker, and Warren R. Carithers- Fundamentals of Computer Graphics, Third Edition by by Peter Shirley and Steve Marschner

Page 2: CMPE 466 COMPUTER GRAPHICS Chapter 5 Attributes of Graphics Primitives Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth

2

State system or state machine and attributes

• A graphics system maintains a list for the current values of attributes and other parameters

• Attributes are referred to as state variables or parameters• Examples of attributes

• Color• Size

• All OpenGL state parameters have default values• Parameters remain in effect until new values are specified

Page 3: CMPE 466 COMPUTER GRAPHICS Chapter 5 Attributes of Graphics Primitives Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth

3

RGB color

Grayscale: When RGB color settings specify an equal amount of R, G, and B,the result is the some shade of gray

Page 4: CMPE 466 COMPUTER GRAPHICS Chapter 5 Attributes of Graphics Primitives Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth

4

Color lookup table or color mapFigure 5-1 A color lookup table with 24 bits per entry that is accessed from a frame buffer with 8 bits per pixel. A value of 196 stored at pixel position (x, y) references the location in this table containing the hexadecimal value 0x0821 (a decimal value of 2081). Each 8-bit segment of this entry controls the intensity level of one of the three electron guns in an RGB monitor.

Extended color capabilitywith less memory requirement

Page 5: CMPE 466 COMPUTER GRAPHICS Chapter 5 Attributes of Graphics Primitives Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth

5

Other color parameters

• Intensity• Quantifies the amount of light energy radiating in a particular

direction over a period of time (physical)

• Luminance• Characterizes the perceived brightness of light (psychological)

Page 6: CMPE 466 COMPUTER GRAPHICS Chapter 5 Attributes of Graphics Primitives Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth

6

OpenGL color functions

• Specifying a single frame buffer and RGB mode

• Selecting the current color

• Selecting display window color

Page 7: CMPE 466 COMPUTER GRAPHICS Chapter 5 Attributes of Graphics Primitives Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth

7

OpenGL point-size function

Page 8: CMPE 466 COMPUTER GRAPHICS Chapter 5 Attributes of Graphics Primitives Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth

8

OpenGL line-style function

• glLineStipple (repeatFactor, pattern);• “pattern” references a 16-bit integer

• A 1 denotes an on pixel position, a 0 denotes an off pixel position• Default value is 0xFFFF

• “repeatFactor” specifies how many times each bit in the pattern is to be repeated before the next bit in the pattern is applied• Default value is 1

Page 9: CMPE 466 COMPUTER GRAPHICS Chapter 5 Attributes of Graphics Primitives Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth

9

OpenGL line-width and line-style functions

/* Define a two-dimensional world-coordinate data type. */

typedef struct { float x, y; } wcPt2D;

wcPt2D dataPts [5];

void linePlot (wcPt2D dataPts [5])

{

int k;

glBegin (GL_LINE_STRIP);

for (k = 0; k < 5; k++)

glVertex2f (dataPts [k].x, dataPts [k].y);

glFlush ( );

glEnd ( );

}

/* Invoke a procedure here to draw coordinate axes. */

glEnable (GL_LINE_STIPPLE);

/* Input first set of (x, y) data values. */

glLineStipple (1, 0x1C47); // Plot a dash-dot, standard-width polyline.

linePlot (dataPts);

/* Input second set of (x, y) data values. */

glLineStipple (1, 0x00FF); // Plot a dashed, double-width polyline.

glLineWidth (2.0);

linePlot (dataPts);

/* Input third set of (x, y) data values. */

glLineStipple (1, 0x0101); // Plot a dotted, triple-width polyline.

glLineWidth (3.0);

linePlot (dataPts);

glDisable (GL_LINE_STIPPLE);

Page 10: CMPE 466 COMPUTER GRAPHICS Chapter 5 Attributes of Graphics Primitives Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth

10

Line-attribute functions

Figure 5-3 Plotting three data sets with three different OpenGL line styles and line widths: single-width dash-dot pattern, double-width dash pattern, and triple-width dot pattern.

Page 11: CMPE 466 COMPUTER GRAPHICS Chapter 5 Attributes of Graphics Primitives Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth

11

OpenGL fill-area functions

… Specification of vertices of polygon …

Page 12: CMPE 466 COMPUTER GRAPHICS Chapter 5 Attributes of Graphics Primitives Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth

12

Texture and interpolation patterns

// Shading mode (default)