OpenGL and Projections

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

1 View Shandong University Software College Instructor: Zhou Yuanfeng
David Luebke5/16/2015 Administrivia l Back on track: canceling OpenGL lecture 2 l Assignment 1 –Greg Yukl found an alternate XForms site:
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
CSC 461: Lecture 51 CSC461 Lecture 5: Simple OpenGL Program Objectives: Discuss a simple program Discuss a simple program Introduce the OpenGL program.
Objectives Learn to build arbitrary transformation matrices from simple transformations Learn to build arbitrary transformation matrices from simple transformations.
1 CSC461 Lecture 7: 3D Programming in OpenGL Objectives: Develop 2D and 3D examples -- Sierpinski gasket: a fractal Develop 2D and 3D examples -- Sierpinski.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 OpenGL Transformations Ed Angel Professor of Computer Science, Electrical and Computer.
OpenGL (II). How to Draw a 3-D object on Screen?
CS 4731: Computer Graphics Lecture 11: 3D Viewing Emmanuel Agu.
OpenGL Tutorial Jason Lawrence COS426 Precept Notes 2/16/04.
3D coordinate systems X Y Z Right-Hand Coordinate System X Y Z Left-Hand Coordinate System OpenGL uses this! Direct3D uses this!
OpenGL Matrices and Transformations Angel, Chapter 3 slides from AW, Red Book, etc. CSCI 6360.
Using OpenGL in Visual C++ Opengl32.dll and glu32.dll should be in the system folder Opengl32.dll and glu32.dll should be in the system folder Opengl32.lib.
Geometric transformations The Pipeline
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Chapter 5 Viewing.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 67 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 67 Computer Graphics Three-Dimensional Graphics III.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
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.
Introduction to GL Geb Thomas. Example Code int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode ( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Demetriou/Loizidou – ACSC330 – Chapter 5 Viewing Dr. Giorgos A. Demetriou Computer Science Frederick Institute of Technology.
Stages of Vertex Transformation To specify viewing, modeling, and projection transformations, you construct a 4 × 4 matrix M, which is then multiplied.
Computer Graphics I, Fall 2010 Computer Viewing.
Modeling with OpenGL Practice with OpenGL transformations.
Intro to OpenGL Transformations CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
Viewing Chapter 5. CS 480/680 2Chapter 5 -- Viewing Introduction: Introduction: We have completed our discussion of the first half of the synthetic camera.
OpenGL Viewing and Modeling Transformation Geb Thomas Adapted from the OpenGL Programming Guidethe OpenGL Programming Guide.
Graphics Graphics Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics I, Fall 2010 OpenGL Transformations.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Transformations.
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.
CGGM Lab. Tan-Chi Ho 2001 Viewing and Transformation.
NoufNaief.net TA: Nouf Al-harbi.
Projections. Viewports Windows can have separate viewports void glViewport(GLint x, GLint y, GLsizei width, GLsizei height ) x, y - Specify the lower.
Transformations Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor.
Introduction to OpenGL & HW1 Announcement 劉軒銘, 網媒所 碩二 ICG 2012 Fall.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Chap 3 Viewing and Transformation
1 OpenGL Transformations. 2 Objectives Learn how to carry out transformations in OpenGL ­Rotation ­Translation ­Scaling Introduce OpenGL matrix modes.
CS559: Computer Graphics Lecture 12: OpenGL - Transformation Li Zhang Spring 2008.
CS559: Computer Graphics Lecture 12: OpenGL: ModelView Li Zhang Spring 2010.
Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
CS5500 Computer Graphics March 20, Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Computer Viewing Isaac Gang University of Mary Hardin-Baylor.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
OpenGL LAB III.
CS380 LAB II OpenGL Donghyuk Kim Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
CSC Graphics Programming
Viewing.
Viewing and Navigating using OpenGL
Computer Viewing.
Isaac Gang University of Mary Hardin-Baylor
Jason Lawrence COS426 Precept Notes 2/16/04
Advanced Graphics Algorithms Ying Zhu Georgia State University
CSC461: Lecture 19 Computer Viewing
Viewing and Navigating using OpenGL
Introduction to Computer Graphics with WebGL
Introduction to OpenGL
University of New Mexico
Computer Graphics Computer Viewing
Computer Viewing Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

OpenGL and Projections David E. Johnson

Goals Quick overview of OpenGL Some derivation of projections and transformations

OpenGL OpenGL is nothing more than a set of functions you call from your program Most functions map to GPU hardware Hides the details of the display adapter, operating system, etc. Has grown to become a flexible general purpose compute platform

As a programmer, you need to Specify the location/parameters of camera. Specify the geometry (and appearance). Specify the lights. OpenGL will compute the resulting 2D image!

Basic Pipeline

Basic Pipeline

OpenGL Hierarchy Several levels of abstraction are provided GL GLU Lowest level: vertex, matrix manipulation glVertex3f(point.x, point.y, point.z) GLU Helper functions for shapes, transformations gluPerspective( fovy, aspect, near, far ) GLUT Highest level: Window and interface management glutSwapBuffers() All fairly raw – most people have their own point class which gets transformed to GL arrays as needed.

OpenGL Implementations OpenGL is an API #include <GL/gl.h> #include <GL/glu.h> #include <GL/glut.h> Windows, Linux, UNIX, etc. all provide a platform specific implementation. Windows: opengl32.lib glu32.lib glut32.lib Linux: -l GL -l GLU –l GLUT

OpenGL Conventions OpenGL is largely state based Calls persist This instead of having functions with 100s of options Transformations live on stacks Layers of transformations possible Work is done on buffers (color, depth,…) Many functions have multiple forms: glVertex2f, glVertex3i, glVertex4dv, etc. Number indicates number of arguments Letters indicate type f: float, d: double, v: pointer, etc. Programs tend to be event based

A simple GLUT program // A simple OpenGL and glut program #include <GL/gl.h> #include <GL/glut.h> void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glFlush(); } int main(int argc, char **argv) glutInit(&argc, argv); glutInitWindowSize(512,512); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH ); glutCreateWindow("The glut hello world program"); glutDisplayFunc(display); glClearColor(0.0, 0.0, 0.0, 1.0); glutMainLoop(); // Infinite event loop return 0;

OpenGL: Camera Two things to specify: Physical location of camera in the scene Where is the camera? Which direction is it pointing? What is the orientation of the camera? Projection properties of the camera Depth of field? Field of view in the x and y directions?

The OpenGL Camera Initially the object and camera frames are the same Default model-view matrix is an identity The camera is located at origin and points in the negative z direction OpenGL also specifies a default view volume that is a cube with sides of length 2 centered at the origin Default projection matrix is an identity

Moving Camera Back default frames frames after translation by –d

Moving the Camera We can move the camera to any desired position by a sequence of rotations and translations Example: side view Rotate the camera Move it away from origin Model-view matrix C = RT

OpenGL code Remember that last transformation specified is first to be applied glMatrixMode(GL_MODELVIEW) glLoadIdentity(); glRotatef(90.0, 0.0, 1.0, 0.0); glTranslatef(0.0, 0.0, -d);

The LookAt Function The GLU library contains the function gluLookAt to form the required modelview matrix through a simple interface Note the need for setting an up direction Still need to initialize Can concatenate with modeling transformations Example: isometric view of cube aligned with axes glMatrixMode(GL_MODELVIEW): glLoadIdentity(); gluLookAt(1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0., 1.0. 0.0);

gluLookAt glLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz)

Projections See notes