Geometric Primitives Used in Open GL Polygons Polygon is : Flat shape with three or more straight sides. It could be either : convex or concave.

Slides:



Advertisements
Similar presentations
Chapter 2: Graphics Programming
Advertisements

1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Programming with OpenGL Part 3: Three Dimensions.
CS 4731 Lecture 2: Intro to 2D, 3D, OpenGL and GLUT (Part I) Emmanuel Agu.
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
Draw a Simple Object. Example 1/4 #include “ glut.h ” void display(); void reshape(GLsizei w, GLsizei h); void main(int argc, char** argv){ glutInit(&argc,
OpenGL (I). What is OpenGL (OGL)? OGL is a 3D graphics & modeling library Can also use it to draw 2D objects.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
1 CSC461 Lecture 7: 3D Programming in OpenGL Objectives: Develop 2D and 3D examples -- Sierpinski gasket: a fractal Develop 2D and 3D examples -- Sierpinski.
Device Independent Graphics and OpenGL
ITEPC 06 - Workshop on Fractal Creation Chiew-Lan Tai and Oscar Au.
Chi-Cheng Lin, Winona State University CS430 Computer Graphics Graphics Programming and OpenGL.
2003CS Hons RW778 Graphics1 Chapter 1: Introduction Admin: Admin: –Lecture slots: Monday 8-9:45, Tuesday 9:15-11:00. –Book: F. Hill, Computer Graphics.
COLOR MODELS 9/12/20151A.ARUNA/ASSISTANT PROFESSOR/SNSCE.
Drawing Basic Graphics Primitives Lecture 4 Wed, Sep 3, 2003.
Computer Graphics using OpenGL, 3 rd Edition F. S. Hill, Jr. and S. Kelley Chapter 2 Initial Steps in Drawing Figures Ureerat Suksawatchon Faculty of Informatics.
Computer Graphics CS 385 January 31, Fractals Some definitions Object which is self-similar at all scales. Regardless of scale the same level of.
1 Figures are extracted from Angel's book (ISBN x) The Human Visual System vs The Pinhole camera Human Visual System Visible Spectrum Pinhole.
CD2012 Principles of Interactive Graphics Lecture 01 Introduction Abir Hussain (Rome: 6.33,Tel , Web:
Introduction to GL Geb Thomas. Example Code int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode ( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
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.
Modeling with OpenGL Practice with OpenGL transformations.
Introduction to Computer Graphics 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
1 Programming with OpenGL Part 3: Three Dimensions Yuanfeng Zhou Shandong University.
Computer Graphics I, Fall 2010 Programming with OpenGL Part 3: Three Dimensions.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Programming with OpenGL Review.
Draw a Simple Object. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture blending.
1 Chapter 2 Graphics Programming. 2 Using OpenGL in Visual C++ – 1/3 Opengl32.dll and glu32.dll should be in the system folder Opengl32.lib and glu32.lib.
Chun-Yuan Lin Introduction to OpenGL 2015/12/19 1 CG.
NoufNaief.net 1 TA: Nouf Al-Harbi.
Doç. Dr. Cemil Öz SAÜ Bilgisayar Mühendisliği Dr. Cemil Öz.
Geometric Primitives Used in Open GL Drawing Triangles glBegin(GL_TRIANGELS); glVertex2i(p0); glVertex2i(p1); glVertex2i(p2); glVertex2i(p3); glVertex2i(p4);
Introduction to OpenGL Programming
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 3: Three Dimensions Ed Angel Professor of Computer Science,
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
31/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 2: Introduction.
OpenGL: Introduction #include main() { OpenWindow() ; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0,
OpenGL Basic Drawing Jian-Liang Lin A Smidgen of OpenGL Code #include main() { InitializeAWindowPlease(); glClearColor (0.0, 0.0, 0.0, 0.0); glClear.
Introduction to OpenGL Muhammad Aamir Khan Lecturer, DCS, UOP.
Introduction to Graphics Programming. Graphics API.
Graphics Graphics Korea University kucg.korea.ac.kr Graphics Programming 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
OpenGL CS418 Computer Graphics John C. Hart. OpenGL: Event-driven How in OpenGL? Programmer registers callback functions Callback function called when.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Computer Graphics -practical- Lecture 6. (visual c++) open gl library To use open GL with VC++ we add these files:- 1)Glut.h C:\program files\ Microsoft.
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 3: Three Dimensions
OpenGL API 2D Graphic Primitives
Programming with OpenGL Part 2: Complete Programs
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
Lighting and Shading Lab 8:.
PROGRAM 8 newpaint.c E. Angel.
Drawing in the plane 455.
Programming with OpenGL Part 3: Three Dimensions
Introduction to OpenGL
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Lecture 12: OpenGL Li Zhang Spring 2008
OpenGL program.
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Starting to draw dealing with Windows which libraries? clipping
Lighting and Shading Lab 8:.
Programming with OpenGL Part 3: Three Dimensions
Programming with OpenGL Part 2: Complete Programs
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Programming with OpenGL Part 3: Three Dimensions
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Presentation transcript:

Geometric Primitives Used in Open GL

Polygons Polygon is : Flat shape with three or more straight sides. It could be either : convex or concave.

Examples of polygons

The Gl_POLYGON Argument The Gl_POLYGON argument : draw close convex polygon which has n points and n>=3. To draw a graphic with internal angles greater than 180 degree: we need to separate it to many convex polygons.

Drawing Polygon glBegin(GL_POLYGON); glVertex2i(p0); glVertex2i(p1); glVertex2i(p2); glVertex2i(p3); glVertex2i(p4); glVertex2i(p5); glVertex2i(p6); glVertex2i(p7); glEnd( ); There are one glBegin () arguments to draw polygons:

Graphic with Internal Angles Greater than 180 Internal Angels Bigger Than 180

Graphic with Internal Angles Greater than 180,Cont.

Example Tree Polygons #include void myInit(void); void myDisplay(void); void main(int argc,char** argv) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(200,200); glutInitWindowPosition(100,100); glutCreateWindow(”Tree"); glutDisplayFunc(myDisplay); myInit(); glutMainLoop(); } void myInit(void) { glClearColor(1.0,1.0,1.0,1.0); gluOrtho2D(0,600,0,600); } void myDisplay(void) { glClear(GL_COLOR_BUFFER_BIT); دالة رسم المضلع ويمثل رأس الشجرة الأخضر // glColor3f(0.0,0.5,0.2) glBegin(GL_POLYGON); glVertex2i(40,80); glVertex2i(60,80); glVertex2i(80,60); glVertex2i(60,40); glVertex2i(40,40); glVertex2i(20,60); glEnd(); دالة رسم المضلع وهو جذع الشجرة البني // glColor3f(0.3,0.2,0.2) glBegin(GL_POLYGON); glVertex2i(60,40); glVertex2i(40,40); glVertex2i(40,10); glVertex2i(60,10); glEnd(); glFlush(); }

Output Tree Polygons

Just take the code of first program, e.g.code of Drawing Point

#include void myInit(void); void myDisplay(void); void main(int argc,char** argv) { glutInit(&argc,argv); //argc= arg count, specifies no. of arguments //argv= arg values, specifies values of those arguments glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(600,600); glutInitWindowPosition(100,100); glutCreateWindow("My first program"); glutDisplayFunc(myDisplay); myInit(); glutMainLoop(); } void myInit(void) { glClearColor(1.0,1.0,1.0,1.0); glColor3f(0.0,0.0, 0.0); glPointSize(50.0); gluOrtho2D(0,600,0,600); } void myDisplay(void) { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POINTS); glVertex2i(300,300); glEnd(); glFlush(); }

We just modify a little in a function: void myInit(void)

Code for point void myDisplay(void) { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POINTS); glVertex2i(300,300); glEnd(); glFlush(); } Code for simple triangle void myDisplay(void) { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_TRIANGLES); glVertex2i(0,0); glVertex2i(300,600); glVertex2i(600,0); glEnd(); glFlush(); } Code for drawing a pointCode for simple triangle void myInit(void) { glClearColor(1.0,1.0,1.0, 1.0); glColor3f(0.0,0.0, 0.0); glPointSize(50); gluOrtho2D(0,600,0,600); } void myInit(void) { glClearColor(1.0,1.0,1.0, 1.0); glColor3f(0.0,0.0, 0.0); nothing gluOrtho2D(0,600,0,600); }

Code for point void myDisplay(void) { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POINTS); glVertex2i(300,300); glEnd(); glFlush(); } Code for simple triangle void myDisplay(void) { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_TRIANGLES); glVertex2i(0,0); glVertex2i(300,600); glVertex2i(600,0); glEnd(); glFlush(); } Code for drawing a pointCode for simple line void myDisplay(void) { glClear(GL_COLOR_BUFFER_BIT) ; glBegin(GL_POINTS); glVertex2i(300,300); glEnd(); glFlush(); } void myDisplay(void) { glClear(GL_COLOR_BUFFER_BIT) ; glBegin(GL_POLYGON); glVertex2i(P1); : glVertex2i(Pn); glEnd(); glFlush(); }

Geometric Primitives Used in Open GL, Cont.

Geometric Primitives Used in Open GL Summery

The End