1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 4: Color and Attributes Isaac Gang University.

Slides:



Advertisements
Similar presentations
Compositing and Blending Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics.
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.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
CSCE 441: Computer Graphics Scan Conversion of Polygons
Implementation III Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
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,
OpenGL and WebGL Drawing Functions CSCI 440 Day Five.
CSC 461: Lecture 6 1 CSC461 Lecture 6: 2D Programming in OpenGL Objectives:  Fundamental OpenGL primitives  Attributes  Viewport.
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
JOGL in MS Windows GDI – Graphics Device Interface (Windows-specific) OpenGL Lib JOGL Commands GDI Processor Graphics Hardware JOGL Lib.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Basic OpenGL Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, September 10, 2003.
Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Emeritus of Computer Science University of New Mexico.
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
1Computer Graphics Implementation III Lecture 17 John Shearer Culture Lab – space 2
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
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,
1 Graphics CSCI 343, Fall 2015 Lecture 4 More on WebGL.
CS 480/680 Intro Dr. Frederick C Harris, Jr. Fall 2014.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
Implementation II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Computer Graphics Basic 3D Geometry CO2409 Computer Graphics Week 5-1.
Computer Graphics Bing-Yu Chen National Taiwan University.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Color and Color Models Angel 2.5 Angel: Interactive Computer Graphics5E © Addison-Wesley
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.
Week 3 Lecture 4: Part 2: GLSL I Based on Interactive Computer Graphics (Angel) - Chapter 9.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
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.
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.
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.
31/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 2: Introduction.
Programming with OpenGL Part 3: Shaders Ed Angel Professor of Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive.
Computer Graphics CC416 Week 14 Filling Algorithms.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran
CS 4722 Made by Dr. Jeffrey Chastine Modified by Dr. Chao Mei
CSC Graphics Programming
University of New Mexico
Introduction to OpenGL
Programming with OpenGL Part 2: Complete Programs
Materi Anatomi OpenGL Fungsi GLUT Posisi Kamera Proyeksi
Objectives Simple Shaders Programming shaders with GLSL
OpenGL API 2D Graphic Primitives
Programming with OpenGL Part 2: Complete Programs
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 4: Color and Attributes
Introduction to Computer Graphics with WebGL
Implementation II Ed Angel Professor Emeritus of Computer Science
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 3: Shaders
Programming with OpenGL Part 4: Color and Attributes
Introduction to OpenGL
Programming with OpenGL Part 2: Complete Programs
Implementation III Ed Angel Professor Emeritus of Computer Science
Implementation II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 4: Color and Attributes Isaac Gang University of Mary Hardin-Baylor

2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Objectives Expanding primitive set Adding color Vertex attributes Uniform variables

3 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 OpenGL Primitives GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_POINTS GL_LINES GL_LINE_LOOP GL_LINE_STRIP GL_TRIANGLES

4 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Polygon Issues OpenGL will only display triangles ­Simple: edges cannot cross ­Convex: All points on line segment between two points in a polygon are also in the polygon ­Flat: all vertices are in the same plane Application program must tessellate a polygon into triangles (triangulation) OpenGL 4.1 contains a tessellator nonsimple polygon nonconvex polygon

Polygon Testing Conceptually simple to test for simplicity and convexity Time consuming Earlier versions assumed both and left testing to the application Present version only renders triangles Need algorithm to triangulate an arbitrary polygon 5 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Good and Bad Triangles Long thin triangles render badly Equilateral triangles render well Maximize minimum angle Delaunay triangulation for unstructured points 6 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Triangularization Convex polygon Start with abc, remove b, then acd, …. 7 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 a c b d

Non-convex (concave) 8 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Recursive Division Find leftmost vertex and split 9 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

10 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Attributes Attributes determine the appearance of objects ­Color (points, lines, polygons) ­Size and width (points, lines) ­Stipple pattern (lines, polygons) ­Polygon mode Display as filled: solid color or stipple pattern Display edges Display vertices Only a few (glPointSize) are supported by OpenGL functions

11 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 RGB color Each color component is stored separately in the frame buffer Usually 8 bits per component in buffer Color values can range from 0.0 (none) to 1.0 (all) using floats or over the range from 0 to 255 using unsigned bytels

12 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Indexed Color Colors are indices into tables of RGB values Requires less memory ­indices usually 8 bits ­not as important now Memory inexpensive Need more colors for shading

13 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Smooth Color Default is smooth shading ­OpenGL interpolates vertex colors across visible polygons Alternative is flat shading ­Color of first vertex determines fill color ­Handle in shader

Setting Colors Colors are ultimately set in the fragment shader but can be determined in either shader or in the application Application color: pass to vertex shader as a uniform variable (next lecture) or as a vertex attribute Vertex shader color: pass to fragment shader as varying variable (next lecture) Fragment color: can alter via shader code 14 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012