Luiz Fernando Martha André Pereira

Similar documents
Assignment 1. Simple Graphics program using OpenGL

CSC 8470 Computer Graphics. What is Computer Graphics?

Computer Graphics. Making Pictures. Computer Graphics CSC470 1

API for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3

Programming with OpenGL Part 2: Complete Programs Computer Graphics I, Fall

Graphics Pipeline & APIs

Computer Graphics. OpenGL

OpenGL. Toolkits.

Precept 2 Aleksey Boyko February 18, 2011

Graphics Programming

Graphics Pipeline & APIs

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

Introduction to Computer Graphics with OpenGL/GLUT

Drawing Primitives. OpenGL basics

Lecture 4 of 41. Lab 1a: OpenGL Basics

Lecture 5b. Transformation

Teacher Assistant : Tamir Grossinger Reception hours: by - Building 37 / office -102 Assignments: 4 programing using

COMPUTER GRAPHICS LAB # 3

Programming using OpenGL: A first Introduction

Questions HW1 Transform Q/A. Transform. Shaoting Zhang. May 11, 2008

Programming of Graphics

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Computer Graphics (Basic OpenGL)

Chapter 3: Modeling Transformation

CS 4204 Computer Graphics

Duc Nguyen CSE 420 Computer Graphics 10/10/2018 Homework 1

Computer graphic -- Programming with OpenGL I

Transformation Pipeline

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL

OpenGL Tutorial. Ceng 477 Introduction to Computer Graphics

Graphics Programming. 1. The Sierpinski Gasket. Chapter 2. Introduction:

C O M P U T E R G R A P H I C S. Computer Graphics. Three-Dimensional Graphics I. Guoying Zhao 1 / 52

CS 428: Fall Introduction to. Transformations in OpenGL + hierarchical modeling. Andrew Nealen, Rutgers, /21/2009 1

Graphics Programming. August 31, Programming of the Sierpinski gasket. Programming with OpenGL and C/C++

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 2: First Program

CS4202: Test. 1. Write the letter corresponding to the library name next to the statement or statements that describe library.

CS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008

Basic Graphics Programming

Transformations. CSCI 420 Computer Graphics Lecture 4

Windows and Viewports. Windows and Viewports. Windows and Viewports. Windows and Viewports. CSC 706 Computer Graphics

Rendering Pipeline/ OpenGL

CS 543 Lecture 1 (Part 3) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Basic Graphics Programming

GL_MODELVIEW transformation

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations

CS418 OpenGL & GLUT Programming Tutorial (I) Presented by : Wei-Wen Feng 1/30/2008

11/1/13. Basic Graphics Programming. Teaching Assistant. What is OpenGL. Course Producer. Where is OpenGL used. Graphics library (API)

Lectures OpenGL Introduction

CSE 167: Lecture #6: Color. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Geometry Primitives. Computer Science Department University of Malta. Sandro Spina Computer Graphics and Simulation Group. CGSG Geometry Primitives

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

OpenGL/GLUT Intro. Week 1, Fri Jan 12

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment

CS559: Computer Graphics. Lecture 12: OpenGL Li Zhang Spring 2008

Two possible ways to specify transformations. Each part of the object is transformed independently relative to the origin

CS 4204 Computer Graphics

Announcements OpenGL. Computer Graphics. Autumn 2009 CS4815

An Interactive Introduction to OpenGL Programming

CSCI E-74. Simulation and Gaming

Computer Graphics. Chapter 7 2D Geometric Transformations

Computer Graphics 1 Computer Graphics 1

Computer Graphics Introduction to OpenGL

Hierarchical Modeling: Tree of Transformations, Display Lists and Functions, Matrix and Attribute Stacks,

ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO EECS 104. Fundamentals of Computer Graphics. OpenGL

Computer Graphics Primitive Attributes

Announcements OpenGL. Computer Graphics. Spring CS4815

Modeling with Transformations

This library uses only GL functions but contains code for creating common objects and simplifying viewing.

Draw the basic Geometry Objects. Hanyang University

RECITATION - 1. Ceng477 Fall

Using GLU/GLUT Objects

Scene Graphs. CS4620/5620: Lecture 7. Announcements. HW 1 out. PA 1 will be out on Wed

COMP 371/4 Computer Graphics Week 1

Reading. Hierarchical Modeling. Symbols and instances. Required: Angel, sections , 9.8. Optional:

Modeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益

OpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL

Lecture 3 Advanced Computer Graphics (CS & SE )

3D Viewing Episode 2

CMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013

C OMPUTER G RAPHICS Thursday

3D computer graphics: geometric modeling of objects in the computer and rendering them

OpenGL. Jimmy Johansson Norrköping Visualization and Interaction Studio Linköping University

1.2 Basic Graphics Programming

Modeling Objects by Polygonal Approximations. Linear and Affine Transformations (Maps)

Lecture 4. Viewing, Projection and Viewport Transformations

Programming with OpenGL Part 1: Background

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

Computer Graphics. Anders Hast. måndag 25 mars 13

Computer Graphics, Chapt 08

Introduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou

2D Drawing Primitives

Fall CSCI 420: Computer Graphics. 2.2 Transformations. Hao Li.

CS380: Computer Graphics 2D Imaging and Transformation. Sung-Eui Yoon ( 윤성의 ) Course URL:

Computer graphics MN1

CSC 470 Computer Graphics

CS 432 Interactive Computer Graphics

CS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II. Emmanuel Agu

The Viewing Pipeline adaptation of Paul Bunn & Kerryn Hugo s notes

OpenGL Transformations

Rendering. Part 1 An introduction to OpenGL

Transcription:

Computer Graphics for Engineering Numerical simulation in technical sciences Color / OpenGL Luiz Fernando Martha André Pereira Graz, Austria June 2014

To Remember

Computer Graphics Data Processing Data Visualization Computer Vision Image - Geometric Modeling - Mesh Generation - Computational Geometry - Visualization Techniques (Post-processing) Imaging Processing

Development Environment C++

Color

COLOR How can one perceive and how to quantify the color?

COLOR How can one perceive and how to quantify the color? Lìght: radiation in a particular range of wavelengths. Light of a single wavelength is called monochormatic. Source: Agrawala, 2014 Lecture Notes on Computer Graphics at UCBerkley

Light at a single frequency R o y G. B i v Bright and distinct in appearance Reproduction only, not a real spectral color! Source: Agrawala, 2014 Lecture Notes on Computer Graphics at UCBerkley

Light at a single frequency R o y G. B i v Bright and distinct in appearance Reproduction only, not a real spectral color! Most colors seen are a mix light of several wavelengths. Curves describe spectral composition of stimulus

Perception -vs-measurement You do not see the spectrum of light Everything is Relative! Source: Agrawala, 2014 Lecture Notes on Computer Graphics at UCBerkley

Perception -vs-measurement You do not see the spectrum of light Everything is Relative! Source: Agrawala, 2014 Lecture Notes on Computer Graphics at UCBerkley

Perception The eye does not see intensity values

Perception The eye does not see intensity values

Eyes as Sensors Eye records color by 3 measurements We can fool it with combination of 3 signals So display devices (monitors, printers, etc.) can generate perceivable colors as mix of 3 primaries Response to stimulus Φ1 is (L1, M1, S1) Response to stimulus Φ2 is (L2, M2, S2) Then response to Φ1+Φ2 is (L1+L2, M1+M2, S1+S2) Response to n Φ1 is (n L1, n M1, n S1) System that obeys superposition and scaling is called a linear system Source: Agrawala, 2014 Lecture Notes on Computer Graphics at UCBerkley

Additive Mixing Given three primaries we agree on p1, p2, p3 Match generic input light with Φ = α p1 + β p2 + γ p3 Negative not realizable, but can add primary to test light. Color now described by α, β, γ Example: computer monitor [R,G,B] Source: Agrawala, 2014 Lecture Notes on Computer Graphics at UCBerkley

Color Matching Functions Input wavelengths are CIE 1931 monochromatic primaries Source: Agrawala, 2014 Lecture Notes on Computer Graphics at UCBerkley

Color Representation

OpenGL

OpenGL OpenGL Programming API (API) for hardware accelerated 2D/3D graphics Platform independent Generic Flexible Low level... Drawing All drawing accomplished using 10 primitives Same basic principle // Draw 4 points glbegin(gl_points) glvertex2i( 50, 50) glvertex2i(50, 50) glvertex2i(50,50) glvertex2i( 50,50) glend() GL_POINTS

GL_LINES GL_LINE_STRIP GL_LINE_LOOP

GL_TRIANGLES GL_TRIANGLE_FAN GL_TRIANGLE_STRIP

GL_QUADS GL_POLYGON GL_QUAD_STRIP

Primitive properties Points and lines Outside glbegin()/glend() line width, gllinewidth(2.0) Point size Color Given on a vertex level Inside glbegin()/glend() Given in RGB, where 1.0 max intensity and 0.0 is minimum intensity Color is interpolated between vertices Color is interpolated between vertices glend(); // Set white color glcolor3f(1.0, 1.0, 1.0); // Set the line width gllinewidth(2.0); glbegin(gl_lines); glvertex2i(-1000,0); glvertex2i(1000,0); glvertex2i(0,-1000); glvertex2i(0, 1000); // Set point size glpointsize(5); glbegin(gl_points); glvertex2i(-50, -50); glvertex2i( 50, -50); glvertex2i( 50, 50); glvertex2i(-50, 50); glend();

glbegin(gl_quads); glcolor3f(1.0, 0.0, 0.0); // Red color glvertex2i(-50, -50); glcolor3f(0.0, 1.0, 0.0); // Green color glvertex2i( 50, -50); glcolor3f(0.0, 0.0, 1.0); // Blue color glvertex2i( 50, 50); glcolor3f(1.0, 1.0, 0.0); // Yellow color glvertex2i(-50, 50); glend();

Geometric transformations Transformations are important in computer graphics Translation Rotation Scaling OpenGL Transformation matrices implemented in hardware Model matrix - glmatrixmode(gl_modelview) Project matrix - glmatrixmode(gl_projection) Initialising matrices // Initialise model view matrix to identity glmatrixmode(gl_modelview) glloadidentity() Translation Translating coordinate systems gltranslatef(x, y, z) Current matrix in multiplied by a translation matrix gltranslatef(40.0,40.0,0.0); glbegin(gl_quads); glcolor3f(1.0,1.0,1.0); glvertex2i( 20, 20); glvertex2i(20, 20); glvertex2i(20,20); glvertex2i( 20,20); glend();

Rotation Rotates coordinate system glrotatef(angle, axis_x, axis_y, axis_z) Right-hand rule Positive Z-axis out of the screen

Rotation Rotates coordinate system glrotatef(angle, axis_x, axis_y, axis_z) Right-hand rule Positive Z-axis out of the screen gltranslatef(40.0,40.0,0.0); glrotatef(30.0,0.0,0.0,1.0); glbegin(gl_quads); glcolor3f(1.0,1.0,1.0); glvertex2i( 20, 20); glvertex2i(20, 20); glvertex2i(20,20); glvertex2i( 20,20); glend();

Scaling Scales current coordinate system glscalef(scale_x, scale_y, scale_z) gltranslatef(40.0,40.0,0.0); glrotatef(30.0,0.0,0.0,1.0); glscalef(2.0,2.0,0.0); glbegin(gl_quads); glcolor3f(1.0,1.0,1.0); glvertex2i( 20, 20); glvertex2i(20, 20); glvertex2i(20,20); glvertex2i( 20,20); glend();

Problem with current method Matrices constantly needs initialising Difficult implement hierarchical tranformations Many matrix multiplications OpenGL Matrix stack Stack of matrices Top is the current matrix If a matrix is added it is assigned the values of the top level matrix. glpushmatrix() Matrices can be discarded using glpopmatrix() Reduce the matrix multiplications Speeds up the code Implemented in hardware

glpushmatrix()/glpopmatrix()

Drawing in the screen buffer Must be cleared for every frame glclear(gl_color_buffer_bit) Background color glclearcolor(red, green, blue) Double buffering Reduces flickering All drawing in back buffer Switch between front and back buffer after drawing Projection and screen view The projection matrix maps model coordinates to screen coordinates glmatrixmode(gl_projection) 2D = Orthographic projection gluortho2d(left, right, top, bottom)

Initializing project matrix // Initiate project matrix glmatrixmode(gl_projection) glloadidentity() // Create a 2D projection matrix gluortho2d(0, width, 0, height) // Initialize the modelview matrix to identity glmatrixmode(gl_modelview) glloadidentity() Viewport Defines where in a window the drawing is to be done glviewport(x,y,width,height) Enables multiple views in a single window Must be updated when window is resized