02/17/05CISC640/440 OpenGL Tutorial1 OpenGL Tutorial CISC 640/440 Computer Graphics TA: Qi Li/Mani Thomas

Slides:



Advertisements
Similar presentations
OpenGL Computer Graphics
Advertisements

Computer Graphics - Viewing -
Department of nskinfo i-education
SI23 Introduction to Computer Graphics
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.
Computer Graphics 2D & 3D Transformation.
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.
MAT 594CM S2010Fundamentals of Spatial ComputingAngus Forbes Overview Goals of the course: 1. to introduce real-time 3D graphics programming with openGL.
Computer Graphics CSCE 441
David Luebke5/16/2015 Administrivia l Back on track: canceling OpenGL lecture 2 l Assignment 1 –Greg Yukl found an alternate XForms site:
FUNDAMENTALS OF PROGRAMMING SM1204 Semester A 2011.
Based on slides created by Edward Angel
Viewing and Transformation
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
CS 352: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
OpenGL and Projections
Computer Graphics (Fall 2008) COMS 4160, Lecture 4: Transformations 2
OpenGL (II). How to Draw a 3-D object on Screen?
Development of Interactive 3D Virtual World Applications
Introduction to OpenGL M. Ramanathan STTP CAD 2011Introduction to OpenGL.
Introduction to OpenGL Jian Huang This set of slides are extracted from the Interactive OpenGL Programming course given by Dave Shreine, Ed Angel and Vicki.
3D coordinate systems X Y Z Right-Hand Coordinate System X Y Z Left-Hand Coordinate System OpenGL uses this! Direct3D uses this!
Transformations of Objects CVG lab. Introduction  Affine transformations : Affine transformations are a fundamental cornerstone of computer graphics.
Computer Graphics, KKU. Lecture 131 Transformation and Viewing in OpenGL.
Geometric transformations The Pipeline
OpenGL and Parametric Curves Advanced Multimedia Technology: Computer Graphics Yung-Yu Chuang 2005/12/21 with slides by Brian Curless, Zoran Popovic, Robin.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Introduction to OpenGL 1. 2 OpenGL A Graphics rendering API introduced in 1992 by Silicon Graphics Inc Provide the low-level functions to access graphics.
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 4: Transformations 2
Stages of Vertex Transformation To specify viewing, modeling, and projection transformations, you construct a 4 × 4 matrix M, which is then multiplied.
Computer Graphics Bing-Yu Chen National Taiwan University.
Computer Graphics I, Fall 2010 Computer Viewing.
Computing & Information Sciences Kansas State University CIS 536/636 Introduction to Computer Graphics Lecture 4 of 41 William H. Hsu Department of Computing.
OpenGL: Introduction Yanci Zhang Game Programming Practice.
Intro to OpenGL Transformations CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
OpenGL Viewing and Modeling Transformation Geb Thomas Adapted from the OpenGL Programming Guidethe OpenGL Programming Guide.
Viewing and Transformation. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture.
The Camera Analogy ► Set up your tripod and point the camera at the scene (viewing transformation) ► Arrange the scene to be photographed into the desired.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
CGGM Lab. Tan-Chi Ho 2001 Viewing and Transformation.
Projections. Viewports Windows can have separate viewports void glViewport(GLint x, GLint y, GLsizei width, GLsizei height ) x, y - Specify the lower.
David Luebke1/5/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Chap 3 Viewing and Transformation
FUNDAMENTALS OF PROGRAMMING SM1204 SEMESTER A 2012.
GL transformations-models. x' = x+t x y' = y+t y z' = z+t z t x t y s x =s y =s z t z uniform nonuniform?!!?? x' = x·s x y' =
CS559: Computer Graphics Lecture 12: OpenGL - Transformation Li Zhang Spring 2008.
1 Geometric Transformations-II Modelling Transforms By Dr.Ureerat Suksawatchon.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Implement of transformation,projection, viewing Hanyang University Jungsik Park.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
OpenGL LAB III.
CS 490: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
CSC Graphics Programming
Administrivia Back on track: canceling OpenGL lecture 2 Assignment 1
Viewing.
School of Computer Science
Computer Viewing.
Isaac Gang University of Mary Hardin-Baylor
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
Computer Graphics, KKU. Lecture 13
Class 12 Complex object with moving parts
Projection in 3-D Glenn G. Chappell
Type of View Perspective View COP(Center of Plane) Diminution of size
University of New Mexico
Computer Graphics 3Practical Lesson
Chapter 3 Viewing.
Presentation transcript:

02/17/05CISC640/440 OpenGL Tutorial1 OpenGL Tutorial CISC 640/440 Computer Graphics TA: Qi Li/Mani Thomas

02/17/05CISC640/440 OpenGL Tutorial2 OpenGL: What is It? GL (Graphics Library): Library of 2-D, 3-D drawing primitives and operations –API for 3-D hardware acceleration GLU (GL Utilities): Miscellaneous functions dealing with camera set-up and higher-level shape descriptions GLUT (GL Utility Toolkit): Window-system independent toolkit with numerous utility functions, mostly dealing with user interface

02/17/05CISC640/440 OpenGL Tutorial3 OpenGL Geometric Primitives GL_QUAD_STRIP GL_POLYGON GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_POINTS GL_LINES GL_LINE_LOOPGL_LINE_STRIP GL_TRIANGLES GL_QUADS

4 Specifying Geometric Primitives Primitives are specified using glBegin(primType);... glEnd(); –primType determines how vertices are combined GLfloat red, green, blue; GLfloat x, y; glBegin(primType); for (i = 0; i < nVerts; i++) { glColor3f(red, green, blue); glVertex2f(x, y);... // change coord. values } glEnd();

5 OpenGL Vertex/Color Command Formats glVertex3fv( v ) Number of components 2 - (x,y) 3 - (x,y,z), (r,g,b) 4 - (x,y,z,w), (r,g,b,a) Data Type b - byte ub - unsigned byte s - short us - unsigned short i - int ui - unsigned int f - float d - double Vector omit “v” for scalar form– e.g., glVertex2f(x, y) glColor3f(r, g, b) glColor3fv( v )

02/17/05CISC640/440 OpenGL Tutorial6 OpenGL 3-D coordinates Right-handed system From point of view of camera looking out into scene:  +X right, - X left  +Y up, - Y down  +Z behind camera, - Z in front Positive rotations are counterclockwise around axis of rotation

02/17/05CISC640/440 OpenGL Tutorial7 Transformations in OpenGl Modeling transformation Viewing transformation Projection transformation

02/17/05CISC640/440 OpenGL Tutorial8 Modeling Transformation Refer to the transformation of models (i.e., the scenes, or objects) Generally, –glMultMatrixf(M_i) Some simple transformations –Translation: glTranslate(x,y,z) –Scale: glScale(sx,sy,sz) –Rotation: glRotate(theta, x,y,z) x,y,z are components of vector defining axis of rotation Angle in degrees; direction is counterclockwise

02/17/05CISC640/440 OpenGL Tutorial9 Viewing Transformation Refer to the transformation on the camera Using glTranslate*() and glRotate*() Using gluLookAt() –gluLookAt (eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ) eye = (eyeX, eyeY, eyeZ) T : Desired camera position center = (centerX, centerY, centerZ) T : Where camera is looking up = (upX, upY, upZ) T : Camera’s “up” vector

02/17/05CISC640/440 OpenGL Tutorial10 Viewing Transformation from Woo et al

02/17/05CISC640/440 OpenGL Tutorial11 Projection Transformation Refer to the transformation from scene to image Orthographic projection –glOrtho (left, right, bottom, top, near, far) from Hill

02/17/05CISC640/440 OpenGL Tutorial12 Projection Transformation Refer to the transformation from scene to image Orthographic projection –glOrtho (left, right, bottom, top, near, far) Perspective projection –glFrustum (left, right, bottom, top, near, far)

02/17/05CISC640/440 OpenGL Tutorial13 Projection Transformation Refer to the transformation from scene to image Orthographic projection –glOrtho (left, right, bottom, top, near, far) Perspective projection –glFrustum (left, right, bottom, top, near, far)

02/17/05CISC640/440 OpenGL Tutorial14 Notes on openGl transformations Before applying modeling or viewing transformations, need to set glMatrixMode(GL_MODELVIEW) Before applying projection transformations, need to set glMatrixMode(GL_Projection) Replacement by either following commands glLoadIdentity(); glLoadMatrix(M); Multiple transformations (either in modeling or viewing) are applied in reverse order

02/17/05CISC640/440 OpenGL Tutorial15 Notes on openGl transformations Before applying modeling or viewing transformations, need to set glMatrixMode(GL_MODELVIEW) Before applying projection transformations, need to set glMatrixMode(GL_Projection) Replacement by either following commands glLoadIdentity(); glLoadMatrix(M); Multiple transformations (either in modeling or viewing) are applied in reverse order