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.

Slides:



Advertisements
Similar presentations
Introduction to OpenGL
Advertisements

2IV60 Computer graphics Graphics primitives and attributes Jack van Wijk TU/e.
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.
CSC 461: Lecture 6 1 CSC461 Lecture 6: 2D Programming in OpenGL Objectives:  Fundamental OpenGL primitives  Attributes  Viewport.
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.
Curso: Graficación Prof. Gueorgi Khatchatourov
Reference1. [OpenGL course slides by Rasmus Stenholt]
CS380 LAB I OpenGL Donghyuk Kim Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
COS 397 Computer Graphics Assoc. Prof. Svetla Boytcheva AUBG 2013 COS 397 Computer Graphics Practical Session №1 Introduction to OpenGL, GLFW and CG.
Basic OpenGL Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, September 10, 2003.
1 GLUT Callback functions Event-driven: Programs that use windows  Input/Output  Wait until an event happens and then execute some pre-defined functions.
Using OpenGL. 2 What is OpenGL? A software interface to graphics hardware It is a Graphics Rendering API (Application Programmer’s Interface) that is.
Drawing Basic Graphics Primitives Lecture 4 Wed, Sep 3, 2003.
Open GL Programming Speaker: 彭任右 Date: 2005/10/3.
Geometric Primitives Used in Open GL Polygons Polygon is : Flat shape with three or more straight sides. It could be either : convex or concave.
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.
2 COEN Computer Graphics I Introductions n Brad Grantham lecturer lab dude n Dave Shreiner lecturer slave driver.
Interactive Computer Graphics Lecture 2: The programming approach to building graphical applications using OpenGL API.
Computer Graphics CS 385 January 31, Fractals Some definitions Object which is self-similar at all scales. Regardless of scale the same level of.
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,
Computer Graphics Bing-Yu Chen National Taiwan University.
On to OpenGL Introduction to Computer Graphics and Animation (Principle of Computer Graphics) Rattapoom Waranusast.
Intro to OpenGL: Vertices and Drawing
UniS CS297 Graphics with Java and OpenGL State Management and Drawing Primative Geometric Objects.
1 CSCE 441 Lecture 2: Scan Conversion of Lines Jinxiang Chai.
NoufNaief.net 1 TA: Nouf Al-Harbi.
Geometric Primitives Used in Open GL Drawing Triangles glBegin(GL_TRIANGELS); glVertex2i(p0); glVertex2i(p1); glVertex2i(p2); glVertex2i(p3); glVertex2i(p4);
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.
CSCE 441: Computer Graphics
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.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 15 Creating 3D Models.
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,
2002 by Jim X. Chen: Drawing Geometric Models.1. Objectives –OpenGL drawing primitives and attributes –OpenGL polygon face.
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.
Graphics Graphics Korea University kucg.korea.ac.kr Graphics Programming 고려대학교 컴퓨터 그래픽스 연구실.
Introduction to OpenGL (INF 250) Veronika Solteszova et al., UiB Dept. of Informatics,
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
OpenGL CS418 Computer Graphics John C. Hart. OpenGL Based on GL (graphics library) by Silicon Graphics Inc. (SGI) Advantages: Runs on everything, including.
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 Lecture 34. OpenGL Programming II Taqdees A. Siddiqi
OpenGL Programming Guide Chapter 2 Korea Univ. Graphics Labs. Ji Jun Yong Korea Univ. Graphics Labs. Ji Jun Yong.
CSC Graphics Programming
The Human Visual System vs The Pinhole camera
State Management and Drawing Geometric Objects
OpenGL API 2D Graphic Primitives
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
OpenGL A Brief Overview.
Class 17 front and back lighting convex sets, convex hull
Lab 3 Geometric Drawing Lab 3 Geometric Drawing.
Objectives OpenGL drawing primitives and attributes
Starting to draw dealing with Windows which libraries? clipping
CSE 411 Computer Graphics Lecture #3 Graphics Output Primitives
Drawing in the plane 455.
Programming with OpenGL Part 2: Complete Programs
Starting to draw dealing with Windows which libraries? clipping
Class 18 front and back lighting convex sets, convex hull
Polygons.
Introduction to OpenGL Programming
OpenGL A Brief Overview.
Presentation transcript:

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 be drawn. Whether and how the vertices are connected is determined by the primitive type.

O PEN GL P RIMITIVES - GL_POINTS Lab Activity (1): Add the following code to display() method. glPointSize(4.0); /* specify point to be 4 pixels thick */ glBegin(GL_POINTS); glVertex2f(0.0f, 2.0f); //note 2D form glVertex2f(1.0f, 2.0f); glVertex2f(0.0f, -2.0f); glVertex2f(-1.0f, 0.0f); glEnd();

O PEN GL P RIMITIVES - LINES  Three different line primitives can be created: GL_LINES: glColor3f(0.0,0.0,0.0); glLineWidth(5.0); glBegin(GL_LINES); glVertex2f (-20.0, -20.0); glVertex2f (20.0, 20.0); glColor3f(1.0,1.0,0.0); glVertex2f (10.0, -20.0); glVertex2f (10.0, 20.0); glEnd();

O PEN GL P RIMITIVES - LINES GL_LINE_STRIP: Draws a connected set of line segments from the first vertex to the last. glColor3f(0.5,0.6,0.0); glLineWidth(4); glBegin(GL_LINE_STRIP); glVertex2f (5.0, 10.0); glVertex2f (10.0, 10.0); glVertex2f (10.0, 0.0); glVertex2f (5.0, 0.0); glEnd();

O PEN GL P RIMITIVES - LINES GL_LINE_LOOP: glColor3f(0.9,0.8,0.0); glLineWidth(4); glBegin(GL_LINE_LOOP); glVertex2f (-10.0, 9.0); glVertex2f (5.0, 9.0); glVertex2f (5.0, -1.0); glVertex2f (-10.0, -1.0); glEnd();

O PEN GL P RIMITIVES – GL_TRIANGES glColor3f(1.0,0.0,1.0); glLineWidth(4); glBegin(GL_TRIANGLES); glVertex2f (-10.0, -10.0); glVertex2f (-5.0, -10.0); glVertex2f (-5.0, -5.0); glEnd();  Insert this command before glLineWidth, and note the effect. glPolygonMode(GL_FRONT, GL_LINE); GL_BACK or GL_FRONT_AND_BACK GL_POINT or GL_FILL - The default is GL_FILL for both front-and back-facing polygons.

O PEN GL P RIMITIVES – GL_TRIANGLE_STRIP glColor3f(0.0,1.0,0.0); glLineWidth(4); glPolygonMode(GL_FRONT, GL_LINE); glBegin(GL_TRIANGLE_STRIP); glVertex2f (-10.0, -10.0); glVertex2f (-19.0, -10.0); glVertex2f (-10.0, -20.0); glVertex2f (-18.0,-19.0); //create 2ndtriangle glVertex2f (-5.0, -25.0); //create 3rd triangle glVertex2f (-20.0, -29.0); //create 4th triangle glEnd(); Note: Order of points does matter! If the vertices are defined clockwise, the front of the polygon will be shown. Otherwise, the back of the polygon will be shown.

O PEN GL P RIMITIVES – GL_TRIANGLE_FAN Draws a connected set of triangles. One triangle is defined for each vertex presented after the first two vertices. Note: Order of points does matter! glColor3f(0.0,0.0,1.0); glLineWidth(4); /* draw only the outline of polygon */ glPolygonMode(GL_FRONT, GL_LINE); glBegin( GL_TRIANGLE_FAN); glVertex2f (12.0, -30.0); glVertex2f(30.0, -30.0); glVertex2f (30.0, -20.0); glVertex2f (22.0, -15.0); glVertex2f (12.0, -12.0); glEnd();

O PEN GL P RIMITIVES – GL_QUADS Note: Order of points does matter! /* creating 2 quadrilaterals */ glColor3f(0.0,0.0,0.0); glPolygonMode(GL_FRONT, GL_LINE); glLineWidth(4); glBegin( GL_QUADS ); glVertex2f (-28.0, 25.0); glVertex2f (-28.0, 10.0); glVertex2f (-20.0, 10.0); glVertex2f (-20.0, 20.0); glVertex2f (-15.0, 20.0); glVertex2f (-2.0, 20.0); glVertex2f (-2.0, 28.0); glVertex2f (-15.0, 28.0); glEnd();

O PEN GL P RIMITIVES – GL_QUAD_STRIP /* creating 2 quadrilaterals using GL_QUAD_STRIP */ glColor3f(0.0,1.0,1.0); glPolygonMode(GL_FRONT, GL_LINE); glLineWidth(4); glBegin( GL_QUAD_STRIP); glVertex2f (20.0, 10.0); glVertex2f (29.0, 13.0); glVertex2f (18.0, 20.0); glVertex2f (26.0, 20.0); glVertex2f (22.0, 25.0); glVertex2f (30.0, 25.0); glVertex2f (15.0, 30.0); glVertex2f (35.0, 30.0); glEnd();

O PEN GL P RIMITIVES – GL_POLYGON glBegin(GL_POLYGON); glVertex2f(2.0,1.0); glVertex2f(12.0,1.0); glVertex2f(14.0,3.0); glVertex2f(1.0,3.0); glEnd();

C REATIVE D RAWING U SING O PEN GL P RIMITIVES

L AB E XERCISE : T IME TO S HOW YOUR C REATIVITY “Sample 2D Scenary are given Lab folder” 1. Show your best to Design your virtual World (2D Scene) onto graph paper.  With Well defined coordinates Points of each object in Scene.  Also Define Color of each Object Of Your Scene Submit ion dates: till Use Open GL built in primitives to Implement your Designed virtual world (2D Scene). Submit ion dates: till