“Computer Science is no more about computers than astronomy is about telescopes.” Professor Edsger Dijkstra.

Slides:



Advertisements
Similar presentations
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
Advertisements

Three-Dimensional Viewing Sang Il Park Sejong University Lots of slides are stolen from Jehee Lee’s.
OpenGL Basics.
#4: OpenGL Implementation & Project 2 CSE167: Computer Graphics TAs: Alex Kozlowski & Cameron Chrisman UCSD, Winter 2006.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
Interactive 3D Graphics and Virtual Reality Introduction to OpenGL concepts Session 2.
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.
Reference1. [OpenGL course slides by Rasmus Stenholt]
CS380 LAB I OpenGL Donghyuk Kim Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
CAP 4703 Computer Graphic Methods Prof. Roy Levow Lecture 2.
Open GL Programming Speaker: 彭任右 Date: 2005/10/3.
3D Viewing.
CSE 470: Computer Graphics. 10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.
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 Figures are extracted from Angel's book (ISBN x) The Human Visual System vs The Pinhole camera Human Visual System Visible Spectrum Pinhole.
Computer Graphics Bing-Yu Chen National Taiwan University.
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.
Three-Dimensional Viewing Jehee Lee Seoul National University.
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.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Three-Dimensional Viewing
Chun-Yuan Lin Introduction to OpenGL 2015/12/19 1 CG.
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.
Graphics: Conceptual Model
Chap 3 Viewing and Transformation
CS552: Computer Graphics Lecture 6: Viewing in 2D.
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 15 Creating 3D Models.
CIS 681 Review: OpenGL. CIS 681 Command Syntax OpenGL commands start with a gl. This is followed by the base command such as Color. Followed by the number.
Introduction to Graphics Programming. Graphics API.
Chapter: Viewing.
Introduction to OpenGL (INF 250) Veronika Solteszova et al., UiB Dept. of Informatics,
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
OpenGL LAB III.
INTRODUCTION TO OPENGL
3 DIMENSIONAL VIEWING Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Computer Graphics Lecture 34. OpenGL Programming II Taqdees A. Siddiqi
Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran
Administrivia Back on track: canceling OpenGL lecture 2 Assignment 1
Three Dimensional Viewing
Computer Graphics CC416 Week 14 3D Graphics.
The Human Visual System vs The Pinhole camera
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
CSCE 441 Computer Graphics 3-D Viewing
Reference1. [OpenGL course slides by Rasmus Stenholt]
Programming with OpenGL Part 2: Complete Programs
Materi Anatomi OpenGL Fungsi GLUT Posisi Kamera Proyeksi
OpenGL API 2D Graphic Primitives
Advanced Graphics Algorithms Ying Zhu Georgia State University
Programming with OpenGL Part 2: Complete Programs
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
OpenGL 2D Viewing Pipeline
Lecture 08 and 09 View & Projection
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University View & Projection.
Drawing in the plane 455.
Introduction to OpenGL
Primitive Objects Lecture 6 Wed, Sep 5, 2007.
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Computer Graphics 3Practical Lesson
3D Viewing.
THREE-DIMENSIONAL VIEWING II
Programming with OpenGL Part 2: Complete Programs
Presentation transcript:

“Computer Science is no more about computers than astronomy is about telescopes.” Professor Edsger Dijkstra

OpenGL Notes & Guides

Required files for Windows In the System Directory glu32.dll opengl32.dll glut32.dll In the C++ Include Directory gl\gl.h l\glu.h gl\glaux.h (probably won't need it) gl\glut.h (includes both gl.h and glu.h) In the C++ Library Directory gl\glu32.lib l\opengl32.lib gl\glaux.lib (probably won't need it) gl\glut32.lib

OpenGL Libraries OpenGL Application GLU GL GLUT GLX Frame Buffer Display

Event Loop OpenGL programs often run in an event loop: Start the program Run some initialization code Run an infinite loop and wait for events such as Key press Mouse move, click Reshape window Expose event

OpenGL Command Syntax (1) OpenGL commands start with “gl” OpenGL constants start with “GL_” Some commands end in a number and one, two or three letters at the end (indicating number and type of arguments) A Number indicates number of arguments Characters indicate type of argument

OpenGL Command Syntax (2) `f' float `d' double float `s' signed short integer `i' signed integer `b' character `ub' unsigned character `us' unsigned short integer `ui' unsigned integer

OpenGL Command Syntax (3) “v” at the end of the name indicates a vector format. Examples: glColor*() glColor3b, glColor3d, glColor3f, glColor3i, glColor3s, glColor3ub, glColor3ui, glColor3us, glColor4b, glColor4d, glColor4f, glColor4i, glColor4s, glColor4ub, glColor4ui, glColor4us, glColor3bv, glColor3dv, glColor3fv, glColor3iv, glColor3sv, glColor3ubv, glColor3uiv, glColor3usv, glColor4bv, glColor4dv, glColor4fv, glColor4iv, glColor4sv, glColor4ubv, glColor4uiv, glColor4usv

OpenGL Primitives GL_POINTS GL_LINES GL_LINE_STRIP GL_LINE_LOOP GL_TRIANGLES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_QUADS GL_QUAD_STRIP GL_POLYGON

Scene Graph Ground T1 Body T4 T2 T3 Head Left Arm Right Arm

OpenGL Program Organization main: find GL visual and create window initialize GL states (e.g. viewing, color, lighting) initialize display lists loop check for events (and process them) if window event (window moved, exposed, etc.) modify viewport, if needed redraw else if mouse or keyboard do something, e.g., change states and redraw redraw: clear screen (to background color) change state(s), if needed render some graphics change more states render some more graphics . swap buffers

glMatrixMode glMatrixMode C Specification Parameters Description - specify which matrix is the current matrix C Specification void glMatrixMode( GLenum mode ) Parameters mode Specifies which matrix stack is the target for subsequent matrix operations. Three values are accepted: GL_MODELVIEW, GL_PROJECTION, and GL_TEXTURE. The default value is GL_MODELVIEW. Description glMatrixMode sets the current matrix mode. mode can assume one of three values: GL_MODELVIEW Applies subsequent matrix operations to the modelview matrix stack. GL_PROJECTION Applies subsequent matrix operations to the projection matrix stack.

Viewing Pipeline

General 3D Viewing Pipeline Modeling coordinates (MC) World coordinates (WC) Viewing coordinates (VC) Projection coordinates (PC) Normalized coordinates (NC) Device coordinates (DC)

Virtual Camera Model Viewing Transformation Projection Transformation The camera position and orientation is determined Projection Transformation The selected view of a 3D scene is projected onto a view plane

Viewing-Coordinate Parameters Look-at point Pref View-up vector V N and V are specified in the world coordinates

Viewing-Coordinate Reference Frame The camera orientation is determined by the uvn reference frame u v n

World-to-Viewing Transformation

Perspective-Projection View Volume Viewing frustum Why do we need near and far clipping plane ?

Normalizing Transformation Transform an arbitrary perspective-projection view volume into the canonical view volume Step 1: from frustum to parallelepiped

Normalizing Transformation Transform an arbitrary perspective-projection view volume into the canonical view volume Step 2: from parallelepiped to normalized

Orthographic Transformation Preserves relative dimension The center of projection at infinity The direction of projection is parallel to a principle axis Architectural and engineering drawings

OpenGL 3D Viewing Functions Viewing-transformation function glMatrixMode(GL_MODELVIEW); gluLookAt(x0,y0,z0,xref,yref,zref,vx,vy,vz); Default: gluLookAt(0,0,0, 0,0,-1, 0,1,0); OpenGL orthogonal-projection function glMatrixMode(GL_PROJECTION); gluOrtho(xwmin,xwmax, ywmin,ywmax, dnear,dfar); Default: gluOrtho(-1,1, -1,1, -1,1); Note that dnear and dfar must be assigned positive values znear=-dnear and zfar=-dfar The near clipping plane is the view plane

glViewport C Specification Parameters void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) Parameters x, y: Specify the lower left corner of the viewport rectangle, in pixels. The initial value is (0, 0). width, height: Specify the width and height of the viewport. When a GL context is first attached to a surface (e.g. window), width and height are set to the dimensions of that surface. glViewport specifies the affine transformation of x and y from normalized device coordinates to window coordinates. Let (xnd, ynd) be normalized device coordinates. Then the window coordinates (xw, yw) are computed as follows:

OpenGL 3D Viewing Functions OpenGL perspective-projection function The projection reference point is the viewing-coordinate origin The near clipping plane is the view plane Symmetric: gluPerspective(theta,aspect,dnear,dfar) General: glFrustum(xwmin,xwmax,ywmin,ywmax,dnear,dfar)