This library uses only GL functions but contains code for creating common objects and simplifying viewing.

Similar documents
2D Drawing Primitives

Pipeline implementation II

Implementation III. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Computer Graphics. OpenGL

Rasterization: Geometric Primitives

CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE

Rasterization, or What is glbegin(gl_lines) really doing?

Computer Graphics. Chapter 3 Computer Graphics Software

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

Line Drawing. Foundations of Computer Graphics Torsten Möller

Realtime 3D Computer Graphics Virtual Reality

Graphics Programming

OpenGL Introduction Computer Graphics and Visualization

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL

Assignment 1. Simple Graphics program using OpenGL

Graphics Programming. August 31, Programming of the Sierpinski gasket. Programming with OpenGL and C/C++

CS 4204 Computer Graphics

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

From Ver(ces to Fragments: Rasteriza(on

Topics. From vertices to fragments

OUTPUT PRIMITIVES. CEng 477 Introduction to Computer Graphics METU, 2007

ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO EECS 104. Fundamentals of Computer Graphics. OpenGL

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

Computer Graphics (Basic OpenGL)

Programming of Graphics

CSCI E-74. Simulation and Gaming

Rendering. Part 1 An introduction to OpenGL

Computer Graphics. Making Pictures. Computer Graphics CSC470 1

Lecture 4 of 41. Lab 1a: OpenGL Basics

CS 591B Lecture 9: The OpenGL Rendering Pipeline

Drawing Primitives. OpenGL basics

Computer Graphics. Chapter 7 2D Geometric Transformations

Fall CSCI 420: Computer Graphics. 7.1 Rasterization. Hao Li.

Digital Differential Analyzer Bresenhams Line Drawing Algorithm

Basic Graphics Programming

Exercise 1 Introduction to OpenGL

Computer Graphics, Chapt 08

Announcements. Midterms graded back at the end of class Help session on Assignment 3 for last ~20 minutes of class. Computer Graphics

Topic #1: Rasterization (Scan Conversion)

CSCI 420 Computer Graphics Lecture 14. Rasterization. Scan Conversion Antialiasing [Angel Ch. 6] Jernej Barbic University of Southern California

CS 4731: Computer Graphics Lecture 21: Raster Graphics: Drawing Lines. Emmanuel Agu

API Background. Prof. George Wolberg Dept. of Computer Science City College of New York

COMP371 COMPUTER GRAPHICS

GLUT. What is OpenGL? Introduction to OpenGL and GLUT

Rasterization. Rasterization (scan conversion) Digital Differential Analyzer (DDA) Rasterizing a line. Digital Differential Analyzer (DDA)

Clipping and Scan Conversion

Rendering approaches. 1.image-oriented. 2.object-oriented. foreach pixel... 3D rendering pipeline. foreach object...

Introduction to Computer Graphics with OpenGL/GLUT

1 Introduction to Graphics

CSC 8470 Computer Graphics. What is Computer Graphics?

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Rendering. A simple X program to illustrate rendering

Teacher Assistant : Tamir Grossinger Reception hours: by - Building 37 / office -102 Assignments: 4 programing using

Tópicos de Computação Gráfica Topics in Computer Graphics 10509: Doutoramento em Engenharia Informática. Chap. 2 Rasterization.

CS Rasterization. Junqiao Zhao 赵君峤

RECITATION - 1. Ceng477 Fall

Part 3: 2D Transformation

3D Transformation. In 3D, we have x, y, and z. We will continue use column vectors:. Homogenous systems:. x y z. x y z. glvertex3f(x, y,z);

OpenGL Graphics System. 2D Graphics Primitives. Drawing 2D Graphics Primitives. 2D Graphics Primitives. Mathematical 2D Primitives.

Rasterization. CS4620/5620: Lecture 12. Announcements. Turn in HW 1. PPA 1 out. Friday lecture. History of graphics PPA 1 in 4621.

Output Primitives. Dr. S.M. Malaek. Assistant: M. Younesi

Programming using OpenGL: A first Introduction

Scan Conversion. Drawing Lines Drawing Circles

Geometry Primitives. Computer Science Department University of Malta. Sandro Spina Computer Graphics and Simulation Group. CGSG Geometry Primitives

CS 543 Lecture 1 (Part 3) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics 1 Computer Graphics 1

CS450/550. Pipeline Architecture. Adapted From: Angel and Shreiner: Interactive Computer Graphics6E Addison-Wesley 2012

Programming with OpenGL Part 2: Complete Programs Computer Graphics I, Fall

Scan Converting Circles

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

CSCI 4620/8626. Coordinate Reference Frames

3D Graphics Pipeline II Clipping. Instructor Stephen J. Guy

Graphics Programming. 1. The Sierpinski Gasket. Chapter 2. Introduction:

Computer graphic -- Programming with OpenGL I

Computer Graphics and Visualization. Graphics Systems and Models

Fundamentals of Computer Graphics. Lecture 3 Generate a simple shape using OpenGL. Yong-Jin Liu

Basic Graphics Programming

The Traditional Graphics Pipeline

Chapter 3: Graphics Output Primitives. OpenGL Line Functions. OpenGL Point Functions. Line Drawing Algorithms

Line Drawing. Introduction to Computer Graphics Torsten Möller / Mike Phillips. Machiraju/Zhang/Möller

1.2 Basic Graphics Programming

Computer Graphics Course 2005

Introduction to OpenGL Week 1

Objectives. Image Formation Revisited. Physical Approaches. The Programmer s Interface. Practical Approach. Introduction to OpenGL Week 1

Rendering. A simple X program to illustrate rendering

Luiz Fernando Martha André Pereira

11/1/13. Basic Graphics Programming. Teaching Assistant. What is OpenGL. Course Producer. Where is OpenGL used. Graphics library (API)

Meshing and Geometry

AC60/AT60 COMPUTER GRAPHICS JUN 2015

The Traditional Graphics Pipeline

Programming with OpenGL Part 1: Background

Graphics System. Processor. Output Display. Input Devices. Frame Buffer. Memory. Array of pixels. Resolution: # of pixels Depth: # of bits/pixel

Early History of APIs. PHIGS and X. SGI and GL. Programming with OpenGL Part 1: Background. Objectives

CS452/552; EE465/505. Clipping & Scan Conversion

CS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II. Emmanuel Agu

Information Coding / Computer Graphics, ISY, LiTH. OpenGL! ! where it fits!! what it contains!! how you work with it 11(40)

Announcement. Homework 1 has been posted in dropbox and course website. Due: 1:15 pm, Monday, September 12

Lecture 5b. Transformation

Computer graphics MN1

COMPUTER GRAPHICS LAB # 3

Transcription:

PES Institute of Technology, Bangalore South Campus (Formerly PES School of Engineering) (Hosur Road, 1KM before Electronic City, Bangalore-560 100) INTERNAL TEST (SCHEME AND SOLUTION) 1 Subject Name: Computer Graphics Subject Code: (13MCA34) 1. About Open GL GLU This library uses only GL functions but contains code for creating common objects and simplifying viewing. Functions in the GLU library begin with the letter glu. GLUT To interface with the window system and to get input from external devices into our programs, we need at least one more library. GLX : OpenGL Extension for the X Window System For the X window system, this library is called GLX WGL for windows, it is wgl WGL or Wiggle is the windowing system interface to the Microsoft Windows implementation of the OpenGL specification. AGL for the macintosh it is agl or(apple graphics library). Rather than using a different library for each system,we use a readily available library called the opengl utility Toolkit(GLUT). GLUT provides minimum functionality that should be expected in any modern windowing system.

OpenGL supports two classes of primitives: Geometric primitives Image (or) raster primitives Geometric primitives Include points, line segments, polygons, curves and surfaces. These primitives pass through a geometric pipeline. where they are subject to a series of geometric operations that determine whether a primitive is visible or not Where on the display it appears if it is visible. 2.DDA Algorithm Digital Differential Analyzer DDA was a mechanical device for numerical solution of differential equations Line y=mx+ h satisfies differential equation dy/dx = m = Dy/Dx = y 2 -y 1 /x 2 -x 1 Along scan line Dx = 1 For(x=x1; x<=x2,ix++) {

y+=m; write_pixel(x, round(y), line_color) } 3.Bresenham s Algorithm DDA requires one floating point addition per step We can eliminate all fp through Bresenham s algorithm Consider only 1 m 0 Other cases by symmetry Assume pixel centers are at half integers If we start at a pixel that has been written, there are only two candidates for the next pixel to be written into the frame buffer More efficient if we look at d k, the value of the decision variable at x = k d k+1 = d k 2Dy, if d k <0 d k+1 = d k 2(Dy- Dx), otherwise For each x, we need do only an integer addition and a test Single instruction on graphics chips 4. Circle: Bresenham algorithm Choice between two pixels: Mid-point algorithm: If the midpoint between pixels is inside the circle, E is closer, draw E If the midpoint is outside, SE is closer, draw SE Error function: d = x 2 +y 2 - r 2 Compute d at the midpoint:

If the last pixel drawn is (x,y), then E = (x+1,y), and SE = (x+1,y-1). Hence, the midpoint = (x+1,y-1/2). d(x,y) = (x+1) 2 + (y - 1/2) 2 - r 2 d < 0: draw E d ³ 0: draw SE In each step (go to E or SE), i.e., increment x: x+=1: d += 2x +3 If I go to SE, i.e., x+=1, y+=-1: d += -2y + 2 The error is not linear However, what I add to the error is Keep Dx and Dy: At each step: Dx += 2, Dy += -2 d += Dx If I decrement y, d += Dy 4 additions per pixel

5. Different types of Graphical functions Primitives (WHAT) Points Line Segments Polygons

Attributes (HOW) Viewing (CAMERA) Transformations Control (GLUT) Input (GLUT) Query (Device independent programs- 2 color) Define the low level objects or atomic entities that our system can display. Depending on the API, the primitives can include Example glbegin(gl_points); glvertex2f(100.0,200.0); glend(); glbegin(gl_lines); glvertex2f(100.0,200.0); glvertex2f(300.0,400.0); glend(); points, line segments, polygons, pixels, text, and various type of curves and surfaces..about Graphical Functions To perform operations ranging from choosing the color with which we display a line segment. Eg glcolor3f(1.0,0.0,0.0); gllinewidth(width); To picking a pattern with which to fill the inside of a polygon.

To selecting a typesafe for the title on a graph. The viewing functions allows us to specify various views,although APIs differ in the degree of flexibility they provide in choosing a view. glviewport (xvmin, yvmin, vpwidth, vpheight); gluortho2d (xwmin, xwmax, ywmin, ywmax); Transformation function that allows to carry out transformations of objects. such as rotation, translation and scaling. Input function gltranslatef (tx, ty, tz); glrotatef (theta, vx, vy, vz); glscalef (sx, sy, sz); Allows us to deal with the diverse forms of input that characterize modern graphics systems. Control function void glutkeyboardfunc(void (*func) (unsigned char key, int x, int y)); Enable us to communicate with the window system, to initialize our programs and to deal with any errors that take place during the execution of our programs. Query function glutinitwindowsize(500,500); How many color are supported or The size of the display. Camera parameters or values in the frame buffer. 6.About open GL Line and Polygon Drawing Functions The primitive and their type specification include the following:.

Points(GL_POINTS): Each vertex is displayed at a size of at least one pixel. Line segments(gl_lines): Successive pairs of vertices to be interpreted as the endpoints of individual segments. Polylines(GL_LINE_STRIP,GL_LINE_LOOP): GL_LINE_STRIP If successive vertices are to be connected, we can use the line strip or polyline form. GL_LINE_LOOP will draw a line segment from the final vertex to the first, thus creating a closed path. Polygons(GL_POLYGON): successive vertices define line segments and a line segment connects the final vertex to the first. use the function glpolygonmode to tell the renderer to generate only the edges or just points for the vertices, instead of fill. glpolygonmode(gl_front_and_back, GL_LINE); Triangle and quadrilaterals (GL_TRIANGLES,GL_QUADS): Successive groups of three and four vertices are interpreted as triangles and quadrilaterals Strips and Fans(GL_TRIANGLE_STRIP, GL_QUAD_STRIP, GL_TRIANGLE_FAN)

groups of triangles or quadrilaterals that share vertices and edges. Triangle strip Each additional vertex is combined with the previous two vertices to define a new triangle. Quadstrip Combine two new vertices with the previous two vertices to define a new quadrilateral. Triangle fan Triangle fan is based on the one fixed point. The next two points determine the first triangle, and subsequent triangles are formed from one new point, the previous point and the first point.