graphics conceptual model l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Graphics: Conceptual Model PowerPoint Presentation
Download Presentation
Graphics: Conceptual Model

Loading in 2 Seconds...

play fullscreen
1 / 41

Graphics: Conceptual Model - PowerPoint PPT Presentation


  • 129 Views
  • Uploaded on

Graphics: Conceptual Model. Real Light. Human Eye. Real Object. Synthetic Light Source. Synthetic Camera. Human Eye. Synthetic Model. Real Object. Display Device. Graphics System. Image: Pixel maps to color. RGB Color Space. G. Green (1,0,0). Yellow (1,1,0). White (1,1,1).

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Graphics: Conceptual Model' - dash


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
graphics conceptual model
Graphics: Conceptual Model

Real Light

Human Eye

Real Object

Synthetic

Light Source

Synthetic

Camera

Human Eye

Synthetic

Model

Real Object

Display

Device

Graphics System

rgb color space

Image: Pixel maps to color

RGB Color Space

G

Green

(1,0,0)

Yellow

(1,1,0)

White

(1,1,1)

Cyan

(0,1,1)

Red

(1,0,0)

R

Blk

Blue

(0,0,1)

Magenta

(1,0,1)

B

color frame buffer
Color Frame Buffer

CRT

Red

D/A

Green

D/A

Blue

D/A

Bit n

1

0

1

1

0

0

1

1

0

1

0

1

Bit 4

Bit 3

Bit 2

Bit 1

rgb color space 12 bit encoding example
RGB Color Space12 Bit Encoding Example

G

[111111110000]

Green

(0, 1, 0)

Yellow

(1,1,0)

White

(1,1,1)

Cyan

(0,1,1)

Red

(1,0,0)

R

Blk

Blue

(0,0,1)

[111100000000]

[000000001111]

Magenta

(1,0,1)

[111100001111]

B

video look up table

1

0

1

1

0

0

1

1

Bit n

Bit 4

Bit 3

Bit 2

Bit 1

Video Look-up Table

= 179

CRT

Look Up Table

Red

D/A

Green

D/A

Blue

D/A

177

178

1

0

1

1

0

0

1

1

0

1

0

1

179

1

0

1

1

0

0

1

1

0

1

0

1

180

computer graphics conceptual model
Computer GraphicsConceptual Model

User Written

Provided by System

Output

Devices

Application

Program

Application

Model

Graphics

System

Input

Devices

computer graphics conceptual model7
Computer GraphicsConceptual Model

API

Output

Devices

Application

Program

Application

Model

Graphics

System

Input

Devices

Function Calls

or Protocol

Data

shared namespace model

O

I

Shared Namespace Model

Model

Application

Function

Calls

} Run in same process

Graphics Lib.

OS

client server model
Client-Server Model:

Model

Application

O

Function

Calls

Graphics

Server

Graphics Lib.

I

OS

OS

Network Protocol

how does application program communicate with graphics system
How does application programcommunicate with graphics system?

???

2D Output Image

(3D) Model

Application

Program

Graphics

System

Input

Devices

two fundamental ways to approach graphics
Two Fundamental Ways to Approach Graphics:

1. Image-Oriented

2. Object-Oriented

1. For each pixel in the image, compute the color

based upon the model of the object(s).

2. For each object, compute the color of all of the

pixels in the image resulting from that object.

object oriented approach
Object-Oriented Approach
  • For each object model, we must compute:
    • Which pixels are affected in the resulting image?
    • What color should they be?
  • How is this computation divided between the user’s program and the graphics system?
  • How are the objects represented in the computer?
  • How is this information communicated to the graphics system (API)?
components of a graphics api
Components of a Graphics API
  • Primitive functions
    • What to draw
  • Primitive attributes
    • How to draw it
  • Transformation functions
    • Rotate, scale, translate objects (where, how big?)
  • Synthetic camera
    • Viewing functions (how to look at it?)
  • Input functions
    • Handle interactivity
  • Control functions
    • Communicate with underlying window system/OS
    • Initialization, error handling, etc.
api design considerations
API Design Considerations

Low

Level

High

Level

Simple

Primitives

Complex

Primitives

Complex

State

Stateless

(Functional)

high vs low level api
High vs. Low Level API
  • High level API
    • API hides detail of actual drawing
    • API defines objects and relationships among objects
    • Example: scene-graph API such as JAVA3D
  • Low level API
    • API exposes detail of actual drawing
    • API defines primitives from which objects are built
    • Example: OpenGL, Direct3D
simple vs complex primitives 2d graphics
Simple (linear)

Point (pixel?}

Line

Polygon

Complex

Glyph (bitmap, subimage)

Curve

Conic section (e.g circle, ellipse)

Arbitrary analytic function

Simple vs. Complex Primitives:2D Graphics

Complex primitives may be built over simple ones.

Linear primitives have advantage in pipeline architecture.

purely functional approach no retained state
Purely Functional Approach (no retained state)

Application

Graphics

Subsystem

Primitives

Attributes

Function

Calls

Graphics

Context

(State)

retained state approach

Graphics

Context

(State)

Retained State Approach

Graphics

Subsystem

Application

Function

Calls

Primitives

Attribute

Functions

opengl command syntax
OpenGL Command Syntax
  • Function calls: glXxxxx[type] ( [args] )
    • Example: glVertex2f (1.0, 2.0);
  • Defined constants: GL_XXXXXXXXXX
    • Example: GL_COLOR_BUFFER_BIT
  • Type definition: GLxxxxxxx
    • Example: GLfloat
opengl primitive syntax
OpenGL Primitive Syntax

glBegin ( type );

glVertex* ( . . . );

.

.

.

.

glVertex* ( . . . );

glEnd ( );

point and line segment primitives

P2

P2

P1

P1

P3

P3

P0

P0

P7

P4

P7

P4

P6

P5

P6

P5

P2

P2

P1

P1

P3

P3

P0

P0

P7

P4

P7

P4

P6

P5

P6

P5

Point and Line Segment Primitives

GL_POINTS

GL_LINES

GL_LINE_STRIP

GL_LINE_LOOP

polygons
Polygons

1. Closed sequence of line segments

2. Has an defined interior

3. Planar

Simple: Well defined interior

Complex:

polygons defining the interior
Polygons: Defining the Interior

Simple: Well defined interior

Complex:

Odd crossings: inside

Even crossings: outside

polygons convexity
Polygons: Convexity

Convex

Non-Convex

P1

P2

Definition extensible to 3D.

polygon primitives

P2

P1

P3

P0

P7

P4

P6

P5

P2

P2

P1

P1

P3

P3

P0

P0

P7

P4

P7

P4

P6

P5

P6

P5

P2

P1

P3

P0

P7

P4

P6

P5

Polygon Primitives

GL_POINTS

GL_POLYGON

P2

P1

P3

P0

P7

P4

P6

P5

GL_TRIANGLES

GL_QUADS

immediate vs retained mode display lists
Immediate vs. Retained ModeDisplay Lists

Creating the Display List:

glNewList(Name, GL_COMPILE);

Attribute 1;

Primitive 1;

Primitive 2;

. . .

Primitive n;

glEndList;

Executing the list:

glCallList(Name);

setting color attribute in opengl rgb mode
Setting Color Attribute in OpenGLRGB Mode

void glColor3{b s i d f d ub ud ui}(TYPE r,

TYPE g, TYPE b);

glColor3f(0.0, 0.0, 0.0); /*black*/

glColor3f(1.0, 0.0, 0.0); /*red*/

glColor3f(0.0, 1.0, 0.0); /*green*/

glColor3f(0.0, 0.0, 1.0); /*blue*/

glColor3f(1.0, 1.0, 0.0); /*yellow*/

glColor3f(0.0, 1.0, 1.0); /*cyan*/

glColor3f(1.0, 0.0, 1.0); /*magenta*/

glColor3f(1.0, 1.0, 1.0); /*white*/

other simple opengl attributes
Other Simple OpenGL Attributes
  • glClearColor(1.0, 1.0, 1.0, 0.0);
    • Sets background color to white
    • Fourth argument is transparency; 0.0 is opaque
    • Sets a state variable
  • glPointSize(2.0);
    • Sets point size to be 2 pixels wide
    • Note that this is not a device-independent attribute
    • Sets a state variable
  • glLinewidth (2.0);
  • glLineStipple(Glint factor, Glushort pattern);
synthetic camera

y

X

(x,y,z)

Z

Xp, Yp, -d

d

Synthetic Camera
synthetic camera projection geometry
Synthetic Camera Projection Geometry

Y

Projected Point

(x’,y’,z’)

X

x,y,z

d

Z

COP

(0,0,0)

Projection Plane

x’ = x (d/z)

y’ = y(d/z)

z’ = d

orthographic projection

x’ = x

y’ = y

z = d

Orthographic Projection

x’ = x (d/z)

y’ = y(d/z)

z’ = d

If d = z - D and d w

transformation matrices in opengl

Load Matrix

Current

Current

Stack

Stack

Transformation Matrices in OpenGL

Matrix Mode

3D

Model

Vertices

2D

3D

Vertices

Modelview

Projection

setting viewing matrix in gl a simple case
Setting Viewing Matrix in GL:A Simple Case

glMatrixMode(GL_PROJECTION);

Sets the switch so that loaded matrix goes into the projection stack.

glLoadIdentity();

Pushes an identity matrix onto the stack;

glOrtho2D(GLdouble left, Gldouble right,

Gldouble bottom, Gldouble top);

Sets the current view to an orthographic projection with view

volume bounded by x = left, x = right, y = bottom, y = top,

z = -1.0 and z = 1.0.

viewport transformation maps clipped projection plane to screen
Viewport TransformationMaps Clipped Projection Plane to Screen

MyWindow

w

Clipping

Window

h

x

y

void glViewport(Glint x, GLint y, GLsizei w, Glsizei h);

Default viewport corresponds to entire window drawable area.

opengl library functions

GLU

GL

GLUT

OpenGL Library Functions

GL library contains all primitive and attribute functions

associated with OpenGL

GLU library builds on the GL library to include more

complex primitives (e.g. spheres) and convenience functions

GLUT (GL Utility Toolkit) includes functions to interface

with the native window system, including window creation,

management of input devices

gl library organization under microsoft windows

GLU

GL

Frame

buffer

GLUT

GL Library Organization Under Microsoft Windows

OpenGl

application

program

Direct Draw

gl library organization under x windows
GL Library Organization (under X Windows)

GLU

GL

OpenGL

application

program

Frame

buffer

GLUT

Xlib, Xtk

GLX

simple glut window management functions
Simple GLUT Window Management Functions

glutInit(int *argc, char** argv);

Initializes a window session.

glutCreateWindow(char *name);

Creates a window with title *name.

glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);

Sets the display mode to single buffered and RGB color.

glutInitWindowSize (GLsizei h, GLsizei w);

Sets initial window size to h x w.

glutInitWindowPosition(x,y);

Sets initial window position to (x, y).

form of simplest glut opengl program
Form of Simplestglut/OpenGL program

#include <glut.h>

/* glut.h includes gl.h and glu.h */

void init (void)

{

/* Usually contains setting of the viewing transformation*/

}

void display (void)

{

/*This function contains all of the draw/redraw commands

}

form of simplest glut opengl program slide 2
Form of Simplestglut/OpenGL program (slide 2)

void reshape (int w, int h)

{

/* What to do whenever the window is resized. Usually includes resetting the viewport */

}

int main (int argc, char ** argv)

{

glutInit(int *argc, char** argv); /* init glut */

glutCreate Window(char *name); /* create window */

glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);

glutInitWindowSize (GLsizei h, GLsizei w);

glutInitWindowPosition(x,y);

init ();

form of simplest glut opengl program slide 3
Form of Simplestglut/OpenGL program (slide 3)

gllutDisplayFunc(display); /* register display */

glutReshapeFunc(reshape); /* register reshape */

glutMainLoop(); /* enter event loop */

return 0;

}