Primitive Objects Lecture 6 Wed, Sep 5, 2007.

Slides:



Advertisements
Similar presentations
School of Computer Science University of Seoul. How can we create a window? How can we handle the events? What kind of objects can we render? How can.
Advertisements

02/17/05CISC640/440 OpenGL Tutorial1 OpenGL Tutorial CISC 640/440 Computer Graphics TA: Qi Li/Mani Thomas
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.
Chapter 2: Graphics Programming
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.
Computer Graphics CSCE 441
CMPE 466 COMPUTER GRAPHICS
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
David Luebke5/16/2015 Administrivia l Back on track: canceling OpenGL lecture 2 l Assignment 1 –Greg Yukl found an alternate XForms site:
2IV60 Computer graphics Graphics primitives and attributes Jack van Wijk TU/e.
© 2004, Tom Duff and George Ledin Jr1 Lectures OpenGL Introduction By Tom Duff Pixar Animation Studios Emeryville, California and George Ledin Jr Sonoma.
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.
Drawing Geometric Objects
1 Lecture 6 Attributes of graphical primitives Colors Colors in OpenGL Algorithms for scan-conversion.
OpenGL and WebGL Drawing Functions CSCI 440 Day Five.
1 Lecture 5 Rendering 3D graphical primitives. 2 3D Rendering Example:
CSC 461: Lecture 6 1 CSC461 Lecture 6: 2D Programming in OpenGL Objectives:  Fundamental OpenGL primitives  Attributes  Viewport.
Reference1. [OpenGL course slides by Rasmus Stenholt]
CS380 LAB I OpenGL Donghyuk Kim Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
3D coordinate systems X Y Z Right-Hand Coordinate System X Y Z Left-Hand Coordinate System OpenGL uses this! Direct3D uses this!
JOGL in MS Windows GDI – Graphics Device Interface (Windows-specific) OpenGL Lib JOGL Commands GDI Processor Graphics Hardware JOGL Lib.
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.
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.
Triangulation Introduction to Computer Graphics and Animation (Principle of Computer Graphics) Rattapoom Waranusast.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
1 Figures are extracted from Angel's book (ISBN x) The Human Visual System vs The Pinhole camera Human Visual System Visible Spectrum Pinhole.
Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition Chapter 2.
Is this a square or a pentagon? It is a square.
Intro to OpenGL Transformations CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
1Computer Graphics Programming with OpenGL Three Dimensions Lecture 06 John Shearer Culture Lab – space 2
Lecture 2: Some definitions of terms 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
Introduction to OpenGL. OpenGL is a low-level graphics library specification. It makes available to the programmer  a small set of geometric primitives.
On to OpenGL Introduction to Computer Graphics and Animation (Principle of Computer Graphics) Rattapoom Waranusast.
Image Synthesis Rabie A. Ramadan, PhD 4. 2 Review Questions Q1: What are the two principal tasks required to create an image of a three-dimensional scene?
UniS CS297 Graphics with Java and OpenGL State Management and Drawing Primative Geometric Objects.
Programming With OpenGL
Chun-Yuan Lin Introduction to OpenGL 2015/12/19 1 CG.
NoufNaief.net 1 TA: Nouf Al-Harbi.
CSCE 441: Computer Graphics
Introduction to OpenGL Programming
Lecture 2 Review OpenGL Libraries Graphics Overview Rendering Pipeline OpenGL command structure.
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.
Introduction to Graphics Programming. Graphics API.
Graphics Graphics Korea University kucg.korea.ac.kr Graphics Programming 고려대학교 컴퓨터 그래픽스 연구실.
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.
OpenGL CS418 Computer Graphics John C. Hart. OpenGL Based on GL (graphics library) by Silicon Graphics Inc. (SGI) Advantages: Runs on everything, including.
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
Administrivia Back on track: canceling OpenGL lecture 2 Assignment 1
CSC Graphics Programming
The Human Visual System vs The Pinhole camera
CS380 Lab Spring Myungbae Son.
Real-Time Rendering Geometry and Buffers
“Computer Science is no more about computers than astronomy is about telescopes.” Professor Edsger Dijkstra.
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
Class 17 front and back lighting convex sets, convex hull
Starting to draw dealing with Windows which libraries? clipping
CSE 411 Computer Graphics Lecture #3 Graphics Output Primitives
Color and Shading Lecture 9 Mon, Sep 26, 2005.
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
Presentation transcript:

Primitive Objects Lecture 6 Wed, Sep 5, 2007

Points and Color Each point (vertex) will assume various attributes, according to the current state of the GPU. The function glColor*() is used to set the current color. Until the color is changed, it is used for each object drawn.

The glColor*() Function The function glColor*() takes 3 or 4 parameters. Red level Green level Blue level Alpha value (for transparency) We will not use the alpha value (much).

OpenGL Function Notation OpenGL does not overload functions. Why not? Therefore, a separate function name must be chosen for each choice of parameter list.

OpenGL Function Notation The * in glColor*() represents any of a list of options: glColor3b() – 3 bytes (unsigned chars). glColor3bv() – array of 3 bytes. glColor3d() – 3 doubles. glColor3dv() – array of 3 doubles. glColor3f() – 3 floats.

OpenGL Function Notation glColor3fv() – array of 3 floats. glColor3i() – 3 integers. glColor3iv() – array of three integers. glColor3s() – 3 shorts. glColor3sv() – array of 3 shorts. glColor3ub() – 3 unsigned bytes. glColor3ubv() – array of 3 unsigned bytes. glColor3ui() – 3 unsigned ints.

OpenGL Function Notation glColor3uiv() – array of 3 unsigned ints. glColor3us() – 3 unsigned shorts. glColor3usv() – array of 3 unsigned shorts. glColor4b() – 4 bytes. glColor4bv() – array of 4 bytes. glColor4d() – 4 doubles. glColor4dv() – array of 4 doubles. glColor4f() – 4 floats.

OpenGL Function Notation glColor4fv() – array of 4 floats. glColor4i() – 4 ints. glColor4iv() – array of 4 ints. glColor4s() – 4 shorts. glColor4sv() – array of 4 shorts. glColor4ub() – 4 unsigned bytes. glColor4ubv() – array of 4 unsigned bytes. glColor4ui() – 4 unsigned ints.

OpenGL Function Notation glColor4uiv() – array of 4 unsigned ints. glColor4us() – 4 unsigned shorts. glColor4usv() – array of 4 unsigned shorts.

The glColor*() Function To draw a red object, make the function call glColor3f(1.0, 0.0, 0.0); before drawing the object. To draw yellow objects, use glColor3f(1.0, 1.0, 0.0);

Primitive Objects OpenGL will draw a number of primitive objects. Points Lines Triangles Quadrilaterals Polygons

Primitive Objects It also draws some more specialized primitive objects Line loops Line strips Triangle strips Quadrilateral strips Triangle fans

Drawing Primitive Objects First, choose the type of object to be drawn. Use glBegin() to specify the type of object and to begin the drawing. Use glEnd() to end the drawing. Between these two function calls, use glVertex*() to list the vertices of the objects.

Drawing Primitive Objects Draw a red triangle. glColor3f(1.0, 0.0, 0.0); glBegin(GL_TRIANGLES); glVertex3f(0.0, 0.0, 0.0); glVertex3f(1.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glEnd();

Drawing Primitive Objects Read Run

Wrapping Direction When drawing a polygon (including triangles and quadrilaterals), the wrapping should be counterclockwise. Counterclockwise wrapping defines the front face. Clockwise wrapping defines the back face.

Drawing Two Triangles Draw a red and a green triangle. glBegin(GL_TRIANGLES); // Draw a red triangle glColor3f(1.0, 0.0, 0.0); glVertex3f(0.0, 0.0, 0.0); glVertex3f(1.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); // Draw a green triangle glColor3f(0.0, 1.0, 0.0); glVertex3f(2.0, 0.0, 0.0); glVertex3f(2.0, 2.0, 0.0); glEnd();

Examples Now, using a set of 12 points, each with a different color, we will draw each kind of object.

Points v0 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Read Run

Lines v0 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Read Run

Triangles v0 v2 v5 v8 v7 v11 v10 v9 v6 v4 v3 v1 Read Run

Quadrilaterals v0 v3 v7 v6 v11 v10 v9 v8 v5 v4 v2 v1 Read Run

Polygon v0 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Read Run

Triangle Fan v0 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Read Run

Line Loop v0 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Read Run

Line Strip v0 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Read Run

Triangle Strip v0 v2 v4 v6 v8 v10 v11 v9 v7 v5 v3 v1 Read Run

Quadrilateral Strip v0 v2 v4 v6 v8 v10 v11 v9 v7 v5 v3 v1 Read Run

Other Shapes All objects that are drawn are composed of these primitive objects. For example, a “circle” is a polygon with so many sides that it looks round. 40 sides is usually sufficient. Curved surfaces consist of may small facets, each of which is a polygon.

A Circle Read Run

A Star OpenGL assumes that all polygons are convex. If we pass OpenGL a star-shaped polygon, it might draw a pentagon.

A Star Read Run

A Sphere Read Run

The GLUT Library GLUT – Graphics Library Utility Toolkit. The GLUT library, generally speaking, contains functions that are related to the windowing system. However, it also contains special functions for drawing spheres and few other solids. glutSolidSphere(radius, stacks, slices) glutWireSphere(radius, stacks, slices)

A GLUT Sphere Read Run