O a polygon is a plane figure specified by a set of three or more coordinate positions, called vertices, that are connected in sequence by straight-Line.

Slides:



Advertisements
Similar presentations
1Introduction A display list is a group of OpenGL commands that have been stored for later execution. Most OpenGL commands can be either stored in a display.
Advertisements

1Computer Graphics Building Models John Shearer Culture Lab – space 2
OpenGL: Simple Use Open a window and attach OpenGL to it Set projection parameters (e.g., field of view) Setup lighting, if any Main rendering loop –Set.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/6103b – Shapes Lecture 03b: Shapes COMP 175: Computer Graphics February 3, 2015.
©Zachary Wartell, UNCC9/28/ :30 AM 1 Overview of OpenGL Revision: 1.2 Copyright Professor Zachary Wartell, University of North Carolina All Rights.
Modeling 靜宜大學資工系 蔡奇偉副教授. 大綱  何謂多邊形?  多邊形的種類  多邊形的正面與反面  填滿多邊形  OpenGL 多邊形相關函式  範例.
CHAPTER 3 2D GRAPHICS ALGORITHMS
CMPE 466 COMPUTER GRAPHICS
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
Polygon Rendering Flat Rendering Goraud Rendering Uses Phong Reflectance Phong Rendering.
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.
3D Game Programming Geometric Transformations
CP411 polygon Lecture 6 1. Scan conversion algorithm for circle 2. Draw polygons 3. Antialiasing.
2 COEN Computer Graphics I Evening’s Goals n Discuss the fundamentals of lighting in computer graphics n Analyze OpenGL’s lighting model n Show.
Computer Graphics(Fall 2003) COMS 4160, Lecture 7: OpenGL 3 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
CS 4363/6353 BASIC RENDERING. THE GRAPHICS PIPELINE OVERVIEW Vertex Processing Coordinate transformations Compute color for each vertex Clipping and Primitive.
University of Sulaimani - School of Science - Computer Dept.
GAM531 DPS931 – Week 11 Render State. The Render State Render State BuffersShadersSamplers Rasterizer State Blend State.
2IV60 Computer graphics Graphics primitives and attributes Jack van Wijk TU/e.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
11-1 Space Figures and Cross Sections
Drawing Geometric Objects
1 Lecture 5 Rendering 3D graphical primitives. 2 3D Rendering Example:
OpenGL Programming Guide (Red Book) State Management and Drawing Geometric Objects 고려대학교 그래픽스 연구실 강 신 진.
Polygons Only one of these is a polygon. Do you know? A polygon MUST be a closed figure.
Drawing Basic Graphics Primitives Lecture 4 Wed, Sep 3, 2003.
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
Geometry 10-1 Solids Face: the flat side of a figure
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt Lines,
State Management and Drawing Geometry Objects
1. OpenGL/GLU/GLUT  OpenGL v4.0 (latest) is the “core” library that is platform independent  GLUT v3.7 is an auxiliary library that handles window creation,
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.
Representation. Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames for.
Identifying 3-D Figures Lesson 12 – 7. Vocabulary Three Dimensional (3 – D) Figure: Shapes that have a length, width, and depth/height Face – a flat surface.
7.1 Three- Dimensional Figures I can classify and draw three-dimensional figures.
Computer Graphics Bing-Yu Chen National Taiwan University.
Polyhedron Platonic Solids Cross Section
Intro to OpenGL: Vertices and Drawing
UniS CS297 Graphics with Java and OpenGL State Management and Drawing Primative Geometric Objects.
Lesson 5 Definition of Rotation and Basic Properties
12.1 Exploring Solids.
Solid Figures Vocabulary.
In the name of God Computer Graphics Bastanfard. Curve Function(2) Other method is approximate it using a poly-line. Just locate a set of points along.
OpenGL Basic Drawing 2003 Spring Keng Shih-Ling
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
Question 1 In which quadrant would the point (3,-4) be located?
CLASSIFYING POLYGONS UNIT 1 LESSON 6. Classifying Polygons In geometry, a figure that lies in a plane is called a plane figure. A polygon is a closed.
Computer Graphics I, Fall 2010 Building Models.
11-1 Space Figures and Cross Sections Objectives To recognize polyhedra and their parts To visualize cross sections of space figures.
7.1 Three- Dimensional Figures I can classify and draw three-dimensional figures.
OpenGL Basic Drawing Jian-Liang Lin A Smidgen of OpenGL Code #include main() { InitializeAWindowPlease(); glClearColor (0.0, 0.0, 0.0, 0.0); glClear.
2002 by Jim X. Chen: Drawing Geometric Models.1. Objectives –OpenGL drawing primitives and attributes –OpenGL polygon face.
Introduction to 3D Solids and Solids of Revolution Some 3D shapes can be formed by revolving a 2D shape around a line (called the axis of revolution).
Polygons Only one of these is a polygon. Do you know? A polygon MUST be a closed figure.
CS 4722 Made by Dr. Jeffrey Chastine Modified by Dr. Chao Mei
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
Draw a Simple Object.
State Management and Drawing Geometric Objects
Rotations Coordinate Algebra 5.3.
Class 17 front and back lighting convex sets, convex hull
Building Models Ed Angel
CSE 411 Computer Graphics Lecture #3 Graphics Output Primitives
Isaac Gang University of Mary Hardin-Baylor
Warm Up Problem Find the area of the trapezoid..
Lecture 13 Clipping & Scan Conversion
Primitive Objects Lecture 6 Wed, Sep 5, 2007.
Chapter VII Rasterizer
Class 18 front and back lighting convex sets, convex hull
Polygons.
Presentation transcript:

O a polygon is a plane figure specified by a set of three or more coordinate positions, called vertices, that are connected in sequence by straight-Line segments, called the edges or sides of the polygon.

O Rectangle is a polygon. O OpenGL provides a filled-rectangle drawing primitive, glRect O We need 2 points to define one rectangle. O gl. glRect{sifd}( x1, y1, x2, y2); x1,y1 x2,y2

O gl.glColor3f(0,1f,0); O gl.glRecti(100,50,-100,-50); OUTPUT

O A polygon has two sides -front and back. O If vertices of polygons appear in counterclockwise order called front-facing. O Because OpenGL by default use counterclockwise then also we use counterclockwise to draw polygon. O We bracket each set of vertices between a call to glBegin() and a call to glEnd().

gl.glBegin(GL2.GL_POLYGON); gl.glVertex2i(-50,75); gl.glVertex2i(-100,0); gl.glVertex2i(-50,-75); gl.glVertex2i(50,-75); gl.glVertex2i(100,0); gl.glVertex2i(50,75); gl.glEnd(); OUTPUT

O Each polygon shape contains of two faces, Front and Back. O By default both of them are Fill O The PolygonMode use to control the polygon faces such as (Fill, Line or Point). Fill Mode Line ModePoint Mode

gl.glPolygonMode(GL2.GL_FRONT,GL2.GL_FILL); gl.glPolygonMode(GL2.GL_BACK,GL2.GL_LINE); gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_POINT); O To change the face of polygon form Front to Back or Back to Front we use gl.glFrontFace(GL2.GL_CW); (ClockWise) gl.glFrontFace(GL2.GL_CCW); (C ounterClockWise)

gl.glPolygonMode(GL2.GL_FRONT,GL2.GL_FILL); gl.glPolygonMode(GL2.GL_BACK,GL2.GL_LINE); gl.glFrontFace(GL2.GL_CW); gl.glBegin(GL2.GL_POLYGON); gl.glVertex2i(0,100); gl.glVertex2i(-75,0); gl.glVertex2i(0,-100); gl.glVertex2i(75,0); gl.glEnd(); OUTPUT

O If you want to highlight the edges of a solid object, you might draw the object with polygon mode set to GL_FILL, and then draw it again, but in a different color and with the polygon mode set to GL_LINE O The problem: Depth values are not the same O This undesirable effect can be eliminated by using polygon offset, which adds an appropriate offset to force coincident z values apart, separating a polygon edge from its highlighting line

O To discard front-or back-facing polygons, use the command glCullFace() and enable culling with glEnable(). O We can discard GL_FRONT,GL_BACK or both faces GL_FRONT_AND_BACK. O Culling enabled using glEnable() with GL_CULL_FACE, and disabled using glDisable()

O gl.glPolygonMode(GL2.GL_FRONT,GL2.GL_FILL); O gl.glPolygonMode(GL2.GL_BACK,GL2.GL_LINE); O gl.glFrontFace(GL2.GL_CCW); O gl.glCullFace(GL2.GL_FRONT); O gl.glEnable(GL2.GL_CULL_FACE); O gl.glBegin(GL2.GL_POLYGON); O gl.glVertex2i(0,100); O gl.glVertex2i(-75,-50); O gl.glVertex2i(75,-50); O gl.glEnd(); O gl.glDisable(GL2.GL_CULL_FACE);

O gl.glEdgeFlag(boolean flag) use to discard the boundary edges of polygon, this method only use with LINE mode of polygon. O used between glBegin() and glEnd(). O boolean flag can be true or false if flag is false then all edges after the glEdgeFlag() command is discarded. O When we want to disable discarding edges we change the flag to true.

O gl.glPolygonMode(GL2.GL_FRONT,GL2.GL_LINE); O gl.glPolygonMode(GL2.GL_BACK,GL2.GL_FILL); O gl.glFrontFace(GL2.GL_CCW); O gl.glBegin(GL2.GL_POLYGON); gl.glEdgeFlag(false); O gl.glVertex2i(100,50); O gl.glEdgeFlag(true); O gl.glVertex2i(-75,50); O gl.glEdgeFlag(false); O gl.glVertex2i(-100,-50); O gl.glEdgeFlag(true); O gl.glVertex2i(75,-50); gl.glEnd();