蔡侑庭 (Yu-Ting Tsai) National Chiao Tung University, Taiwan. Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification

Similar documents
Computer Graphics. Chapter 7 2D Geometric Transformations

蔡侑庭 (Yu-Ting Tsai) National Chiao Tung University, Taiwan. Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

3D Graphics Pipeline II Clipping. Instructor Stephen J. Guy

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Transformation Pipeline

Prof. Feng Liu. Fall /19/2016

Lecture 4 of 41. Lab 1a: OpenGL Basics

CSCI E-74. Simulation and Gaming

Getting Started. Overview (1): Getting Started (1): Getting Started (2): Getting Started (3): COSC 4431/5331 Computer Graphics.

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

GL_MODELVIEW transformation

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

CSE 167: Introduction to Computer Graphics Lecture #5: Projection. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017

Describe the Orthographic and Perspective projections. How do we combine together transform matrices?

7. 3D Viewing. Projection: why is projection necessary? CS Dept, Univ of Kentucky

CS 591B Lecture 9: The OpenGL Rendering Pipeline

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

Spring 2013, CS 112 Programming Assignment 2 Submission Due: April 26, 2013

Computer Graphics Geometric Transformations

Viewing COMPSCI 464. Image Credits: Encarta and

CS Computer Graphics: Transformations & The Synthetic Camera

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

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

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

OpenGL. Toolkits.

3D Transformation. In 3D, we have x, y, and z. We will continue use column vectors:. Homogenous systems:. x y z. x y z. glvertex3f(x, y,z);

CSC 470 Computer Graphics

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

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

CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011

Precept 2 Aleksey Boyko February 18, 2011

12. Selection. - The objects selected are specified by hit records in the selection buffer. E.R. Bachmann & P.L. McDowell MV 4202 Page 1 of 13

Mobile Application Programming: Android. OpenGL ES 3D

Overview of Projections: From a 3D world to a 2D screen.

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

Today. Rendering pipeline. Rendering pipeline. Object vs. Image order. Rendering engine Rendering engine (jtrt) Computergrafik. Rendering pipeline

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

OpenGL Transformations

An Interactive Introduction to OpenGL Programming

Transformations. CSCI 420 Computer Graphics Lecture 4

CSE 167: Introduction to Computer Graphics Lecture #4: Vertex Transformation

1 (Practice 1) Introduction to OpenGL

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

Computer Graphics. Chapter 5 Geometric Transformations. Somsak Walairacht, Computer Engineering, KMITL

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

E.Order of Operations

Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D

Viewing Transformation

Mobile Application Programming. OpenGL ES 3D

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

Projection: Mapping 3-D to 2-D. Orthographic Projection. The Canonical Camera Configuration. Perspective Projection

Geometry: Outline. Projections. Orthographic Perspective

CS 543: Computer Graphics. Projection

Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt

Viewing and Projection

Viewing and Projection

CS380: Computer Graphics Viewing Transformation. Sung-Eui Yoon ( 윤성의 ) Course URL:

OpenGL: A Practical Introduction. (thanks, Mark Livingston!)

COMP Computer Graphics and Image Processing. 5: Viewing 1: The camera. In part 1 of our study of Viewing, we ll look at ˆʹ U ˆ ʹ F ˆʹ S

Computer Graphics. Bing-Yu Chen National Taiwan University

C OMPUTER G RAPHICS Thursday

Fachhochschule Regensburg, Germany, February 15, 2017

Modeling with Transformations

CS 4204 Computer Graphics

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Rendering Pipeline and Coordinates Transforms

3D Viewing Episode 2

Computer Graphics 7: Viewing in 3-D

Computer Graphics Hands-on

Computer Graphics (Basic OpenGL)

Introduction to OpenGL

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

Mouse Ray Picking Explained

Something noteworthy

Computer graphics MN1

Introduction to OpenGL

OpenGL: Setup 3D World

3.1 Viewing and Projection

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

Transforms 3: Projection Christian Miller CS Fall 2011

OpenGL/GLUT Intro. Week 1, Fri Jan 12

CS 428: Fall Introduction to. Viewing and projective transformations. Andrew Nealen, Rutgers, /23/2009 1

6. Modelview Transformations

Advanced Computer Graphics (CS & SE )

Viewing with Computers (OpenGL)

COMP3421. Introduction to 3D Graphics

CITSTUDENTS.IN VIEWING. Computer Graphics and Visualization. Classical and computer viewing. Viewing with a computer. Positioning of the camera

Chap 3 Viewing Pipeline Reading: Angel s Interactive Computer Graphics, Sixth ed. Sections 4.1~4.7

Viewing/Projections IV. Week 4, Fri Feb 1

Graphics Programming

COMP3421. Week 2 - Transformations in 2D and Vector Geometry Revision

COMP3421. Introduction to 3D Graphics

Transformations. CSCI 420 Computer Graphics Lecture 5

COMP 175 COMPUTER GRAPHICS. Lecture 07: Scene Graph. COMP 175: Computer Graphics March 10, Remco Chang 07 Scene Graph

Transformations. OpenGL Transformations. 4x4 Model-view Matrix (this lecture) OpenGL Transformation Matrices. 4x4 Projection Matrix (next lecture)

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

An Interactive Introduction to OpenGL and OpenGL ES Programming. Ed Angel Dave Shreiner

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

Transcription:

蔡侑庭 (Yu-Ting Tsai) Department of Computer Science National Chiao Tung University, Taiwan Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification OpenGL Programming Guide, Chap. 3 & Appendix F

2 OpenGL Buffers Five Basic Steps for GLUT Initialize GLUT Initialize Buffers Create Display Window Set Event Routines Start Event Parsing Loop GLUT Event Routines

3 Sample Code http://caig.cs.nctu.edu.tw/course/cg2007/files/ week_ 3.zip void MyDisplay() {... } void MyReshape( int nwidth, int nheight ) {... }

4 Eye Coordinates Normalized Device Coordinates Clip C di t Coordinates

5 y y z x x Left-Handed Coordinates z Right-Handed Coordinates OpenGL

6 Unified Way to Treat OpenGL Coordinates In most cases, w o is 1 (default value) Camera is always at the origin [0, 0, 0, 1] T Viewing direction always points toward negative z-axis Transformations are applied only to object coordinates Vice versa

7 Transformation matrices remain in effect until you change them OpenGL is a state t machine Call glloadidentity to reset transformation matrices if needed Each transformation at o function call Multiplies its result with current matrix Changes current matrix

8 g glmatrixmode( ( GL_MODELVIEW ); glloadidentity(); gltranslate( tx, tx ty, ty tz ); glrotate( θ, rx, ry, rz ); glscale( sx, sy, sz ); Eye Coordinates

9 Transformations are applied to object coordinates in reverse order glmatrixmode( GL_MODELVIEW ); gltranslate( tx, ty, tz ); glrotate( θ, rx, ry, rz ); glscale( sx, sy, sz ); glbegin( GL_POLYGON ); glend();

10 Rotations are applied to object coordinates with respect to the origin gltranslate( tx, ty, tz ); glrotate( θ, rx, ry, rz ); glrotate( θ, rx, ry, rz ); gltranslate( tx, ty, tz ); glbegin( GL_POLYGON ); glbegin( GL_POLYGON ); y y x x z z

11 g glmatrixmode( ( GL_PROJECTION ); glloadidentity(); glortho( l, l rr, b b, tt, n n, f ); [ glfrustum( l, r, b, t, n, f ); ] [ gluperspective( θ, aspect, n, f ); ] Eye Coordinates Clip Coordinates

12 glortho( l, r, b, t, n, f ) y l t z Camera x b n r f

13 glfrustum( l, r, b, t, n, f ) y l t z Camera x b n r f

14 gluperspective( θ, aspect = w / h, n, f ) y w z Camera x θ n h f

15 Automatically Performed by OpenGL (Graphics Hardware) Clip Coordinates Normalized Device Coordinates

16... gldepthrange( l, l u ); glviewport( x, y, w, h ); Normalized Device Coordinates

17 glviewport( x, y, w, h )& gldepthrange( l, u ) h [x, y] w

18 glviewport( x, y, w, h )& gldepthrange( l, u ) The y-axis of window coordinates points upward Normalized device coordinates [-1, 1] [-1, 1] [-1, 1] Mapped to [x, x + w] [y, y + h] [l, u]

19 Uniform Spacing (Orthographic) v e [-n, -f] v c [-1, 1] v d [-1, 1] v w [l, u] Camera

20 Non-Uniform Spacing (Perspective) v e [-n, -f] v c [-n, f] v d [-1, 1] v w [l, u] Camera

21 OpenGL Coordinate System Right-Handed Coordinates Basic OpenGL Transformations Modelview Transformations Translation, rotation, & scale Projection Transformations Orthographic & perspective projection Viewport Transformation

22 More on OpenGL Transformations Discussion on Assignment I Recitation of Selected Topics?

23 How to achieve non-uniform depth spacing for orthographic projection?

24 How to achieve uniform depth spacing for perspective projection?

25 Prof. Wen-Chieh Lin s CG Slides OpenGL Specifications http://www.opengl.org/documentation/specs/ OpenGL Programming Guide, Chap. 3 & Appendix F Sudhansu K. Semwal s OpenGL Tutorial http://www.cs.uccs.edu/~semwal/indexgltutorial. html

26 Thank You! Any Questions?