The Human Visual System vs The Pinhole camera

Slides:



Advertisements
Similar presentations
OpenGL CMSC340 3D Character Design & Animation. What is OpenGL? A low-level graphics library specification designed for use with the C and C++ provides…
Advertisements

Chapter 2: Graphics Programming
Computer Graphics CSCE 441
Pemrograman OpenGL Dasar
© 2004, Tom Duff and George Ledin Jr1 Lectures OpenGL Introduction By Tom Duff Pixar Animation Studios Emeryville, California and George Ledin Jr Sonoma.
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
CSC 461: Lecture 51 CSC461 Lecture 5: Simple OpenGL Program Objectives: Discuss a simple program Discuss a simple program Introduce the OpenGL program.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner OpenGL, GLUT, Transformations.
30/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 1: Introduction.
CENG477 Introduction to Computer Graphics Introduction to OpenGL, GLUT and GLUI.
Interactive 3D Graphics and Virtual Reality Introduction to OpenGL concepts Session 2.
CSE 494/598 Intro to Applied Computer Graphics Anshuman Razdan DCST AR's Web Page AR's Web Page
Computer Graphics CS 385 February 7, Fundamentals of OpenGl and Glut Today we will go through the basics of a minimal OpenGl Glut project, explaining.
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.
Chapter 03: Graphics Primitives Course web page: Chapter #3.
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.
Computer Graphics Bing-Yu Chen National Taiwan University.
Basic OpenGL Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, September 10, 2003.
1 GLUT Callback functions Event-driven: Programs that use windows  Input/Output  Wait until an event happens and then execute some pre-defined functions.
Using OpenGL. 2 What is OpenGL? A software interface to graphics hardware It is a Graphics Rendering API (Application Programmer’s Interface) that is.
Introduction to OpenGL and GLUT GLUT. What is OpenGL? An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality.
2 COEN Computer Graphics I Introductions n Brad Grantham lecturer lab dude n Dave Shreiner lecturer slave driver.
CSE 470: Computer Graphics. 10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.
Ch 2 Graphics Programming page 1 CSC 367 Coordinate Systems (2.1.2) Device coordinates, or screen coordinates (pixels) put limitations on programmers and.
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.
Computing & Information Sciences Kansas State University CIS 536/636 Introduction to Computer Graphics Lecture 4 of 41 William H. Hsu Department of Computing.
Introduction to OpenGL and GLUT. What’s OpenGL? An Application Programming Interface (API) A low-level graphics programming API – Contains over 250 functions.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 43 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 43 Computer Graphics Programming with OpenGL I.
Program 2 due 02/01  Be sure to document your program  program level doc  your name  what the program does  each function  describe the arguments.
Chun-Yuan Lin Introduction to OpenGL 2015/12/19 1 CG.
NoufNaief.net TA: Nouf Al-harbi.
GLUT functions glutInit allows application to get command line arguments and initializes system gluInitDisplayMode requests properties for the window.
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
Graphics: Conceptual Model
CSCE 441: Computer Graphics
Introduction to OpenGL Programming
Lecture 2 Review OpenGL Libraries Graphics Overview Rendering Pipeline OpenGL command structure.
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
OpenGL: Introduction #include main() { OpenWindow() ; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0,
Introduction to OpenGL Muhammad Aamir Khan Lecturer, DCS, UOP.
Introduction to Graphics Programming. Graphics API.
Graphics Graphics Korea University kucg.korea.ac.kr Graphics Programming 고려대학교 컴퓨터 그래픽스 연구실.
Introduction to Graphics Programming. Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
INTRODUCTION TO OPENGL
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran
Programming with OpenGL Part 1: Background
“Computer Science is no more about computers than astronomy is about telescopes.” Professor Edsger Dijkstra.
Programming with OpenGL Part 2: Complete Programs
Materi Anatomi OpenGL Fungsi GLUT Posisi Kamera Proyeksi
OpenGL API 2D Graphic Primitives
Programming with OpenGL Part 2: Complete Programs
Graphics Programming (I)
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
גרפיקה ממוחשבת: מבוא ל-OpenGL
Introduction to OpenGL
Interactive Computer Graphics Graphics Programming
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
OpenGL, GLUT, Transformations I Week 2, Wed Jan 16
Programming with OpenGL Part 2: Complete Programs
Presentation transcript:

The Human Visual System vs The Pinhole camera Visible Spectrum Human Visual System Pinhole camera Figures are extracted from Angel's book (ISBN 0-201-38597-x)

The Synthetic-camera Model Figures are extracted from Angel's book (ISBN 0-201-38597-x)

Synthetic Camera y (x,y,z) X Z d Xp, Yp, -d

Synthetic Camera Projection Geometry Projected Point (x’,y’,z’) X x,y,z d Z COP (0,0,0) Projection Plane x’ = x (d/z) y’ = y(d/z) z’ = d

Introduction to Graphics Programming

Graphics API

Computer Graphics Conceptual Model API Output Devices Application Program Application Model Graphics System Input Devices Function Calls or Protocol Data

Components of a Graphics API Primitive functions What to draw Attribute functions How to draw it Viewing functions (how to look at it) Transformation functions Rotate, scale, translate objects (where, how big?) Input functions Handle interactivity Control functions Communicate with window system Initialization, error handling

API Design Considerations Simple Primitives Complex Primitives Complex State Stateless (Functional)

OpenGL and GLUT Overview

What Is OpenGL? Graphics rendering API high-quality color images composed of geometric and image primitives window system independent operating system independent developed by SGI OpenGL is a library for doing computer graphics. By using it, you can create interactive applications which render high-quality color images composed of 3D geometric objects and images. OpenGL is window and operating system independent. As such, the part of your application which does rendering is platform independent. However, in order for OpenGL to be able to render, it needs a window to draw into. Generally, this is controlled by the windowing system on whatever platform you’re working on.

Major decisions Simple primitive Retained State Approach Not interactive with native windows

Major decisions Simple primitive Retained State Approach Not interactive with native windows

Point and Line Segment Primitives GL_POINTS GL_LINES P0 P1 P2 P3 P4 P5 P6 P7 P0 P1 P2 P3 P4 P5 P6 P7 GL_LINE_STRIP GL_LINE_LOOP P0 P1 P2 P3 P4 P5 P6 P7 P0 P1 P2 P3 P4 P5 P6 P7

Polygon Primitives GL_POINTS GL_POLYGON P0 P1 P2 P3 P4 P5 P6 P7 P2 P1 GL_TRIANGLES GL_QUADS P0 P1 P2 P3 P4 P5 P6 P7 P0 P1 P2 P3 P4 P5 P6 P7

Polygons OpenGL only supports rendering for simple, convex and flat polygon 1. Closed 2. Has an interior Simple: Well defined interior Complex: Simple: No pair of edges of a polygon cross each other

Polygons: Convexity P1 P2 Definition extensible to 3D. Convex Non-Convex P1 P2 Definition extensible to 3D.

OpenGL Primitive Syntax glBegin ( type ); glVertex* ( . . . ); . glEnd ( );

Simple Example glBegin( GL_QUADS ); glColor3fv( color ); glVertex2f( 0.0, 0.0 ); glVertex2f( 1.0, 0.0 ); glVertex2f( 1.5, 1.118 ); glVertex2f( 0.5, 1.118 ); glEnd(); The drawRhombus() routine causes OpenGL to render a single quadrilateral in a single color. The rhombus is planar, since the z value is automatically set to 0.0 by glVertex2f().

OpenGL Command Formats glVertex3fv( v ) Number of components Data Type Vector b - byte ub - unsigned byte s - short us - unsigned short i - int ui - unsigned int f - float d - double omit “v” for scalar form glVertex2f( x, y ) The OpenGL API calls are designed to accept almost any basic data type, which is reflected in the calls name. Knowing how the calls are structured makes it easy to determine which call should be used for a particular data format and size. For instance, vertices from most commercial models are stored as three component floating point vectors. As such, the appropriate OpenGL command to use is glVertex3fv( coords ). As mentioned before, OpenGL uses homogenous coordinates to specify vertices. For glVertex*() calls which don’t specify all the coordinates ( i.e. glVertex2f()), OpenGL will default z = 0.0, and w = 1.0 . 2 - (x,y) 3 - (x,y,z) 4 - (x,y,z,w)

Major decisions Simple primitive Retained State Approach Not interactive with native windows

Setting Color Attribute in OpenGL RGB Mode void glColor3{b s i d f ub ud ui}(TYPE r, TYPE g, TYPE b); glColor3f(0.0, 0.0, 0.0); /*black*/ glColor3f(1.0, 0.0, 0.0); /*red*/ glColor3f(0.0, 1.0, 0.0); /*green*/ glColor3f(0.0, 0.0, 1.0); /*blue*/ glColor3f(1.0, 1.0, 0.0); /*yellow*/ glColor3f(0.0, 1.0, 1.0); /*cyan*/ glColor3f(1.0, 0.0, 1.0); /*magenta*/ glColor3f(1.0, 1.0, 1.0); /*white*/

Other Simple OpenGL Attributes glClearColor(1.0, 1.0, 1.0, 0.0); Sets background color to white Fourth argument is transparency; 0.0 is opaque Sets a state variable glPointSize(2.0); Sets point size to be 2 pixels wide Note that this is not a device-independent attribute glLinewidth (2.0);

Immediate vs. Retained Mode Display Lists Creating the Display List: glNewList(Name, GL_COMPILE); Attribute 1; Primitive 1; Primitive 2; . . . Primitive n; glEndList; Executing the list: glCallList(Name);

Major decisions Simple primitive Retained State Approach Not interact with native windows

OpenGL Library Functions GL library contains all primitive and attribute functions associated with OpenGL GLU GLU library builds on the GL library to include more complex primitives (e.g. spheres) and convenience functions GLUT (GL Utility Toolkit) includes functions to interface with the native window system, including window creation, management of input devices GLUT

GL Library Organization Under Microsoft Windows GLU GL OpenGl application program Frame buffer GLUT Direct Draw

GL Library Organization (under X Windows) GLU GL OpenGL application program Frame buffer GLUT Xlib, Xtk GLX

Geometry Pipeline

Vertices Vertices in world coordinates void glVertex3f(GLfloat x, GLfloat y, GLfloat z) Vertex (x, y, z) sent down the pipeline

Transformer Transformer in world coordinates Complex [Angel Ch. 4] Must be set before object is drawn! glRotatef(45.0, 0.0, 0.0, -1.0); glVertex2f(1.0, 0.0); Complex [Angel Ch. 4]

Transformation Matrices in OpenGL Load Matrix Matrix Mode 3D Model Vertices Stack Current Stack Current 2D 3D Vertices Modelview Projection

Setting Viewing Matrix in GL: A Simple Case glMatrixMode(GL_PROJECTION); Sets the switch so that loaded matrix goes into the projection stack. glLoadIdentity(); Pushes an identity matrix onto the stack; gluOrtho2D(GLdouble left, Gldouble right, Gldouble bottom, Gldouble top); Sets the current view to an orthographic projection with view volume bounded by x = left, x = right, y = bottom, y = top, z = -1.0 and z = 1.0.

Clipper

Viewport Transformation MyWindow w Clipping Window h x y void glViewport(Glint x, GLint y, GLsizei w, Glsizei h); Default viewport corresponds to entire window drawable area.

Projector

Orthographic Projection x’ = x (d/z) y’ = y(d/z) z’ = d If d = z - D and d w x’ = x y’ = y z = d

Rasterizer

Simple GLUT Window Management Functions glutInit(int *argc, char** argv); Initializes a window session. glutCreateWindow(char *name); Creates a window with title *name. glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); Sets the display mode to single buffered and RGB color. glutInitWindowSize (GLsizei h, GLsizei w); Sets initial window size to h x w. glutInitWindowPosition(x,y); Sets initial window position to (x, y).

Form of Simplest glut/OpenGL program #include <glut.h> /* glut.h includes gl.h and glu.h */ void init (void) { /* Usually contains setting of the viewing transformation*/ } void display (void) /*This function contains all of the draw/redraw commands

Form of Simplest glut/OpenGL program (slide 2) void reshape (int w, int h) { /* What to do whenever the window is resized. Usually includes resetting the viewport */ } int main (int argc, char ** argv) glutInit(int *argc, char** argv); /* init glut */ glutCreate Window(char *name); /* create window */ glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); glutInitWindowSize (GLsizei h, GLsizei w); glutInitWindowPosition(x,y); init (); glutDisplayFunc(display); /* register display */ glutReshapeFunc(reshape); /* register reshape */ glutMainLoop(); /* enter event loop */ return 0;

GLUT Callback Functions Routine to call when something happens window resize or redraw user input animation “Register” callbacks with GLUT glutDisplayFunc( display ); glutIdleFunc( idle ); glutKeyboardFunc( keyboard );

Rendering Callback Do all of your drawing here glutDisplayFunc( display ); void display( void ) { glClear( GL_COLOR_BUFFER_BIT ); glBegin( GL_QUADS ); glVertex3fv( v[0] ); glVertex3fv( v[1] ); glVertex3fv( v[2] ); glVertex3fv( v[3] ); glEnd(); glFlush (); }

Idle Callbacks Use for animation and continuous update glutIdleFunc( idle ); void idle( void ) { t += dt; glutPostRedisplay(); }

Simple hello world