o a polygon is a plane figure specified by a set of three or more coordinate positions, called...
TRANSCRIPT
![Page 1: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/1.jpg)
Polygon Details
![Page 2: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/2.jpg)
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.
What is the Polygon?
![Page 3: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/3.jpg)
RectangleO Rectangle is a polygon.O OpenGL provides a filled-rectangle drawing
primitive, glRectO We need 2 points to define one rectangle.O gl. glRect{sifd}( x1, y1, x2, y2);
x1,y1
x2,y2
![Page 4: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/4.jpg)
Rectangle ex.O gl.glColor3f(0,1f,0);
Ogl.glRecti(100,50,-100,-50);
OUTPUT
![Page 5: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/5.jpg)
PolygonO 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().
![Page 6: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/6.jpg)
Polygon Ex.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
![Page 7: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/7.jpg)
Class Activity
![Page 8: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/8.jpg)
Geometric Drawing Primitives
![Page 9: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/9.jpg)
Geometric Drawing Primitives
![Page 10: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/10.jpg)
Polygon face ModeO Each polygon shape contains of two faces, Front and
Back.O By default both of them are FillO The PolygonMode use to control the polygon faces
such as (Fill, Line or Point).
Fill Mode Line Mode Point Mode
![Page 11: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/11.jpg)
Polygon face Modegl.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); (CounterClockWise)
![Page 12: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/12.jpg)
Polygon face Mode Ex.
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
![Page 13: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/13.jpg)
Class Activity
![Page 14: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/14.jpg)
Polygon Offset
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 sameO 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
![Page 15: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/15.jpg)
Polygon Offset
![Page 16: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/16.jpg)
Polygon Offset
![Page 17: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/17.jpg)
Culling Polygon Faces
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()
![Page 18: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/18.jpg)
Culling Polygon Faces Ex.
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);
![Page 19: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/19.jpg)
Discarding Boundary Edges
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.
![Page 20: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/20.jpg)
EdgeFlag() Ex.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();
![Page 21: 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](https://reader036.vdocument.in/reader036/viewer/2022062515/56649c765503460f94929ec1/html5/thumbnails/21.jpg)
HomeWork