Graphics Output Primitives

Slides:



Advertisements
Similar presentations
©Zachary Wartell, UNCC9/28/ :30 AM 1 Overview of OpenGL Revision: 1.2 Copyright Professor Zachary Wartell, University of North Carolina All Rights.
Advertisements

CHAPTER 3 2D GRAPHICS ALGORITHMS
CMPE 466 COMPUTER GRAPHICS
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Building Models modified by Ray Wisman Ed Angel Professor of Computer Science,
1 Building Models. 2 Objectives Introduce simple data structures for building polygonal models ­Vertex lists ­Edge lists OpenGL vertex arrays.
2IV60 Computer graphics Graphics primitives and attributes Jack van Wijk TU/e.
CMPE 466 COMPUTER GRAPHICS Chapter 5 Attributes of Graphics Primitives Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth.
Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 21 Today’s class Graphics programming Color.
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
CSCE 441: Computer Graphics Scan Conversion of Polygons
Drawing Geometric Objects
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D.
1 CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai.
CS 4731: Computer Graphics Lecture 22: Raster Graphics Part 3 Emmanuel Agu.
Computer Graphics CS 385 February 7, Fundamentals of OpenGl and Glut Today we will go through the basics of a minimal OpenGl Glut project, explaining.
Reference1. [OpenGL course slides by Rasmus Stenholt]
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Attributes of Graphics Primitives Sang Il Park Sejong University.
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
GRAPHICS OUTPUT PRIMITIVES CA 302 Computer Graphics and Visual Programming Aydın Öztürk
1/24/20061 Fill-Area Algorithms and Functions. 1/24/20062 Learning Objectives OpenGL state variables Color and gray scale Color functions Point attributes.
JOGL in MS Windows GDI – Graphics Device Interface (Windows-specific) OpenGL Lib JOGL Commands GDI Processor Graphics Hardware JOGL Lib.
Drawing in OpenGL CSC 2141 Introduction to Computer Graphics.
Drawing Basic Graphics Primitives Lecture 4 Wed, Sep 3, 2003.
Triangulation Introduction to Computer Graphics and Animation (Principle of Computer Graphics) Rattapoom Waranusast.
Speeding Up Rendering After Deciding What to Draw.
CSE 470: Computer Graphics. 10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
1 Introduction Line attribute Color and gray scale Area filled attribute Anti-aliasing.
State Management and Drawing Geometry Objects
1 Figures are extracted from Angel's book (ISBN x) The Human Visual System vs The Pinhole camera Human Visual System Visible Spectrum Pinhole.
P RACTICING O PEN GL- P RIMITIVES. O PEN GL O UTPUT P RIMITIVES  Each geometric object is described by a set of vertices and the type of primitive to.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
Computer Graphics Bing-Yu Chen National Taiwan University.
Sang Il Park Sejong University
Attributes of Graphics Primitives Hearn & Baker Chapter 4 Some slides are taken from Robert Thomsons notes.
Chun-Yuan Lin Introduction to OpenGL 2015/12/19 1 CG.
What are Computer Graphics Basically anything that is on you Monitor – This includes the text that you will see Text isn’t Advanced Graphics But…. Understanding.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
Computer Graphics I, Fall 2010 Building Models.
31/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 2: Introduction.
CIS 681 Review: OpenGL. CIS 681 Command Syntax OpenGL commands start with a gl. This is followed by the base command such as Color. Followed by the number.
Introduction to Graphics Programming. Graphics API.
Attributes of Graphics Primitives Chapter 4
Introduction to OpenGL (INF 250) Veronika Solteszova et al., UiB Dept. of Informatics,
Introduction to Graphics Programming. Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
Chapter 8 Three-dimensional Object Representations PART I
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
CSC Graphics Programming
Attributes of Graphics Primitives Hearn & Baker Chapter 4
Scan Conversion of Polygons
COIS712/ECOM708/COIS800 Chapter 4 Graphics Output Primitives (Part II)
Polygon Filling Algorithms
COIS712/ECOM708/COIS800 Chapter 5 Attributes of Graphics Primitives
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
Lab 3 Geometric Drawing Lab 3 Geometric Drawing.
Starting to draw dealing with Windows which libraries? clipping
גרפיקה ממוחשבת: מבוא ל-OpenGL
Agenda Polygon Terminology Types of polygons Inside Test
Project 1: Into Space! CG Concepts Needed
CSE 411 Computer Graphics Lecture #3 Graphics Output Primitives
Display Lists & Text Glenn G. Chappell
Agenda Polygon Terminology Types of polygons Inside Test
Starting to draw dealing with Windows which libraries? clipping
Polygons.
Presentation transcript:

Graphics Output Primitives Sang Il Park Sejong University

2D Fill-Area Primitives

Irregular curved fill region Fill-Area Primitives Circular fill region Irregular curved fill region Polygonal fill region Tessellation

POLYGON Polygon: a plane figure specified by a set of vertices connected with sequence of straight-line segments ex) triangles, rectangles, pentagons, octagons, ... How to represent: a sequence of the vertices ( vertex list )

Polygon Representation Using Tables: 1. Vertex table, edge table, surface table 2. Vertex table, surface table

OpenGL polygon fill-area functions Rectangular fill area: glRect* (x1,y1,x2,y2) glRecti (50, 50, 200, 200) int pt1 [] = {50, 50}; int pt2 [] = {200,200}; glRectiv (pt1, pt2);

OpenGL polygon fill-area functions OpenGL에서의 그림 그리기는 다음과 같은 Begin-End 절로 표현 http://www.opengl.org/sdk/docs/man/xhtml/glBegin.xml 예) glBegin (종류); ……… glEnd ( ); GL_POLYGON GL_TRIANGLES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_QUADS GL_QUAD_STRIP glBegin (GL_POLYGONS); glVertex2iv (pt1); glVertex2iv (pt2); glVertex2iv (pt3); glVertex2iv (pt4); glVertex2iv (pt5); glEnd ( );

OpenGL Vertex Arrays An efficient way to send the vertex data glEnableClientState (GL_VERTEX_ARRAY); glVertexPointer (2, GL_INT, 0, pt); GLubyte vertIndex [] = {1, 2, 3, 4, 4, 3, 5, 6}; glDrawElements (GL_QUADS,8, GL_UNSIGNED_BYTE, vertIndex);

OpenGL Display List An comvenient, efficient way to store an object Execute a display list: glNewList (listID, listMode ); // your drawing routine glEndList(); listID: a unique name for the list (GLuint). Use glGenLists(1) to obtain a valid ID listMode: GL_COMPILE / GL_COMPILE_AND_EXECUTE glCallList(listID);

GLUT display reshape function Reshape (or resize) callback: when changing the window size Registration: Implementation: glutReshapeFunc ( MyReshape ); void MyReshape (int w, int h) { // your reshaping code such as gluOrtho2D }

OpenGL Pixel-Array Primitives Bitmap: using a bit for representing each pixel Pixmap: using several bytes for each pixel

OpenGL Pixel-Array Primitives glBitmap: draw a bitmap on the screen Glubyte bitmap [20] = { 0x1c,0x00,0x1c,0x00,0x1c,0x00,0x1c,0x00, 0x1c,0x00,0xff,0x80,0x7f,0x00,0x3e,0x00, 0x1c,0x00,0x08,0x00}; glPixelStorei (GL_UNPACK_ALIGHMENT, 1); glRasterPos2i(30,40); glBitmap( 9, 10, 0.0, 0.0, 20.0, 15.0, bitmap);

OpenGL Pixel-Array Primitives glDrawPixels: draw a pixmap on the screen glDrawPixels ( width, height, dataFormat, dataType, pixMap);

Text-Drawing Painting programs Drawing programs bit-mapped representation e.g., Adobe Photoshop, bit-map fonts Drawing programs object-based representation e.g., Powerpoint, outline fonts

OpenGL Text Drawing Bitmap text: Ex) glutBitmapCharacter (font, char ) GLUT_BITMAP_8_BY_13 GLUT_BITMAP_9_BY_15 GLUT_BITMAP_TIMES_ROMAN_10 … http://www.opengl.org/resources/libraries/glut/spec3/node76.html char a[]=“abced”; glrasterPosition2i(100,100); for(int i=0;i<5;i++) glutBitmapCharacter (GLUT_BITMAP_8_BY_13, a[i]);

연습 교재 page 181~189 까지 직접 입력해서 실행해 보고, 그 내용을 분석해 볼 것

Ch.4. Attributes of Graphics Primitives

OpenGL State variables: Color Point attributes Line attributes Fill-Area attributes

Color in OpenGL Color buffer Setting: Setting the color value: Ex) glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB) GLUT_RGBA GLUT_RGB GLUT_INDEX GLUT_SINGLE GLUT_DOUBLE glColor* (values); glColor3f (0.0, 1.0, 0.5); glColor3i ( 0, 255, 128);

Point Attributes in OpenGL Size: Color : glPointSize ( size ); glColor* (values);

Line Attributes in OpenGL Width: Line-Style : ex) Line-Style On/Off: glLineWidth ( width ); glLineStipple (repeatFactor, pattern); glLineStipple (1, 0x00FF); glLineStipple (1, 0x0101); glEnable (GL_LINE_STIPPLE); glDisable (GL_LINE_STIPPLE);

Other Line Attributes Not in OpenGL Line Caps: Connecting: Butt cap Round cap Projecting square cap Miter join Round join Bevel join

Other Line Attributes Not in OpenGL Pen and Brush Options:

Color in OpenGL Color buffer Setting: Setting the color value: Ex) glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB) GLUT_RGBA GLUT_RGB GLUT_INDEX GLUT_SINGLE GLUT_DOUBLE glColor* (values); glColor3f (0.0, 1.0, 0.5); glColor3i ( 0, 255, 128);

Area Filling Scan line approach Seed Fill Algorithm

Area Filling (Scan line Approach) For each scan line (1) Find intersections (the extrema of spans) Use Bresenham's line-scan algorithm (2) Sort intersections (increasing x order) (3) Fill in between pair of intersections

Area Filling (Scan line Approach) Take advantage of Edge coherence: edges intersected by scan line i are also intersected by scan line i+1

Area Filling (Scan line method)

Area Filling (Seed Fill Algorithm) basic idea Start at a pixel interior to a polygon Fill the others using connectivity seed

Seed Fill Algorithm (Cont’) 4-connected 8-connected Need a stack. Why?

Seed Fill Algorithm (Cont’) start position

Seed Fill Algorithm (Cont’) 8 6 4 2 0 2 4 6 8 10 0 2 4 6 8 10 8 6 4 2 interior-defined boundary-defined flood fill algorithm boundary fill algorithm

Seed Fill Algorithm (Cont’) 0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 hole boundary pixel interior pixel seed pixel The stack may contain duplicated or unnecessary information !!!

Boundary Filling

Flood Filling : Start a point inside the figure, replace a specified interior color only.

Scan Line Seed Fill scan line conversion seed filling + Shani, U., “Filling Regions in Binary Raster Images: A Graph-Theoretic Approach”, Computer Graphics, 14, (1981), 321-327

Boundary Filling Efficiency in space! finish the scan line containing the starting position process all lines below the start line process all lines above the start line

Problems of Filling Algorithm What happens if a vertex is shared by more than one polygon, e.g. three triangles? What happens if the polygon intersects itself? What happens for a “sliver”? Solutions? Redefine what it means to be inside of a triangle Different routines for nasty little triangles

Aliasing in CG Which is the better?