CSE 470: Computer Graphics. 10/15/2015 2 Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.

Slides:



Advertisements
Similar presentations
OpenGL Open a Win32 Console Application in Microsoft Visual C++.
Advertisements

Coordinate System.
CMPE 466 COMPUTER GRAPHICS
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
Computer Graphics using OpenGL, 3 rd Edition F. S. Hill, Jr. and S. Kelley Chapter 3 Additional Drawing Tools Ureerat Suksawatchon Department of Computer.
Informationsteknologi Monday, November 12, 2007Computer Graphics - Class 71 Today’s class Viewing transformation Menus Mandelbrot set and pixel drawing.
Viewing and Transformation
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,
OpenGL (II). How to Draw a 3-D object on Screen?
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.
Picking. What is picking? Selecting an object on the screen What does this require? –Get Mouse Location –Compute what objects are rendered at the position.
CAP 4703 Computer Graphic Methods Prof. Roy Levow Lecture 2.
GLWidget Description Jason Goffeney 3/8/2006. GLWidget The GLWidget class extends the Qt QGLWidget. The QGLWidget is a Qt Widget that happens to have.
Computer Graphics, KKU. Lecture 131 Transformation and Viewing in OpenGL.
The Viewing Pipeline (Chapter 4) 5/26/ Overview OpenGL viewing pipeline: OpenGL viewing pipeline: – Modelview matrix – Projection matrix Parallel.
Geometric transformations The Pipeline
Korea University Korea University Computer Graphics Laboratory Computer Graphics Laboratory Jung Lee, Chapter 13.
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.
OpenGL: Introduction Yanci Zhang Game Programming Practice.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
MAE152 Computer Graphics for Scientists and Engineers Fall 03 Display Lists.
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.
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.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
1 Graphics CSCI 343, Fall 2015 Lecture 6 Viewing, Animation, User Interface.
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.
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
GLUT functions glutInit allows application to get command line arguments and initializes system gluInitDisplayMode requests properties for the window.
Graphics: Conceptual Model
Chap 3 Viewing and Transformation
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.
31/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 2: Introduction.
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.
Graphics Graphics Korea University kucg.korea.ac.kr Graphics Programming 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
OpenGL CS418 Computer Graphics John C. Hart. OpenGL Based on GL (graphics library) by Silicon Graphics Inc. (SGI) Advantages: Runs on everything, including.
OpenGL CS418 Computer Graphics John C. Hart. OpenGL: Event-driven How in OpenGL? Programmer registers callback functions Callback function called when.
OpenGL LAB III.
Computer Graphics Lecture 41 Viewing Using OpenGL Taqdees A. Siddiqi
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
The Human Visual System vs The Pinhole camera
“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
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
Project 1: Into Space! CG Concepts Needed
Coordinate Systems and Transforming the Coordinates
Introduction to OpenGL
OpenGL program.
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Computer Graphics 3Practical Lesson
CS297 Graphics with Java and OpenGL
Programming with OpenGL Part 2: Complete Programs
Presentation transcript:

CSE 470: Computer Graphics

10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type (like floating point) A 3D vertex: glVertex3f(GLfloat x, GLfloat y, GLfloat z); Example: A 3D vertex using integer values: glVertex3i(4, 5, 2);

10/15/ Connecting the Dots glBegin(GL_LINES); GL_LINES connects pairs of points. (x1, y1) (x2, y2) (x3, y3) (x4, y4) glVertex2f(x1, y1); glVertex2f(x2, y2); glVertex2f(x3, y3); glVertex2f(x4, y4); glEnd();

10/15/ Other Drawing functions GL_LINE_STRIP: Connect each consecutive point with previous one. p1 p2 p3 p4 p5 p6 p1 p2 p3 p4 p1p2 p3p4 GL_LINE_LOOP: Same as line strip, except also connects last point with first point. GL_POLYGON: Vertices define the vertices of a polygon. Polygons have special properties that differ from line loops (e.g. you can fill in a polygon).

10/15/ Polygons Polygons have an interior that can be filled. Polygons are used in graphics systems to create surfaces. Curved surfaces can be approximated by many small polygons. Polygons can be rendered (drawn on the screen) rapidly. The interior of the polygon must be well defined. It must be: –Simple, convex and flat.

10/15/ Well behaved polygons Simple polygons: No pair of edges cross. Convex polygons: A line between any two points inside the polygon or on the boundary lies completely within the object Flat polygons: All vertices must lie in the same plane. This is trivial if the polygon is a triangle, but takes some work for polygons with more than 3 sides. Simple Not Simple Convex p1 p2 Not Convex

10/15/ The Clipping Volume The region of the scene that's imaged is the clipping volume. (Or the clipping rectangle for 2D images). near far left right top bottom Regions outside the clipping volume are not rendered.

10/15/ Specifying the clipping volume In 3D: void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far); In 2D: void glOrtho2D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top); (glOrtho2D sets near and far to -1.0 and 1.0 respectively)

10/15/ Orthographic projection Orthographic projection sets all Z values to zero. Point P = (X, Y, Z), will project to image point p = (x, y) where x = X and y = Y Y Z P = (Xp, Yp, Zp) Yp

10/15/ View Ports Clipping window is defined in world coordinates. OpenGL renders the image in screen coordinates. OpenGL must translate the image from world coordinates to the screen pixel coordinates. The drawing region on the screen is called the viewport.

10/15/ Defining a viewport void glViewPort(GLint x, GLint y, GLsizei w, GLsizei h); (x, y) w h Lower left-hand corner

10/15/ Mapping from world to screen Want entire image from the clipping region to be mapped onto the entire viewport. Therefore, you need to make the height/width (aspect ratio) the same for both (or you will get a distorted image). ClippingViewPort hchc wcwc wvwv hvhv

10/15/ Callback functions glut handles specific events using callback functions. Program specifies which function should be called for a given event. When a particular event occurs, the specified function is called to handle the event. The display() function is a callback function. We will create callback functions for menus, mouse clicks, etc.

10/15/ OpenGL Functions glutDisplayFunc() – an event callback function. Whenever GLUT determines that the contents of the window need to be redisplayed, the callback function registered by glutDisplayFunc() is executed. You should put all routines need to redraw in the display callback function. glutReshapeFunc() – indicates what action should be taken when the window is resized. The glutReshapeFunc() is a callback function that specifies the function that is called whenever the window is resized or moved. Typically, the function that is called when needed by the reshape function displays the window to the new size and redefines the viewing characteristics as desired. If glutReshapeFunc() is not called, a default reshape function is called which sets the view to minimize distortion and sets the display to the new height and width.

10/15/ Orthographic: Orthographic projection maps objects directly onto the screen without affecting their relative sizes. This projection is used mainly in architectural and computer-aided design applications, where the actual measurements of the objects are more important than how they might look. The command glFrustum() is used to set the projection transformation. The command glMatrixMode() is used, with the argument GL_PROJECTION is used to indicate that the current matrix specifies the projection transformation and that subsequent transformation calls affect the projection matrix. Note that we use the glLoadIdentity() command to initialize the current projection matrix so that only the specified projection transformation(s) have an effect. Finally, we calle the command glOrtho() to create an orthographic parallel viewing volume. The viewing volume is a box with the left, right, top, bottom, near and far edges specified in the glOrtho() command.glFrustum()glMatrixMode()glLoadIdentity()glOrtho() When it is time to perform transformations on the models that we have created, we will use the same glMatrixMode() command with GL_MODELVIEW as the argument. This indicates that the succeeding transformations now affect the modelview matrix instead of the projection matrix.glMatrixMode() Orthographic

10/15/ glPushMatrix() – save the current transformation state by copying the matrix on the top of the matrix stack which was last referenced by the glMatrixMode() command. This top matrix can then be translated and drawn, as desires, and ultimately destroyed using the glPopMatrix() command. This leaves you right where you were before and ready to repeat the process for the next version of the object. glPopMatrix() -- restore to previous transformation state. Matrix Stack

10/15/ Animation glutIdleFunc() – The Idle Callback specifies a function that is involked whenever the system is not handling any other callbacks or events. glutSwapBuffers() – double-buffering - hardware or software that supplies two complete color buffers. One is displayed while the other is being drawn. When the drawing of a frame is complete, the two buffers are swapped, so the one that was being viewed is now used for drawing, and vice versa. With double-buffering, every frame is shown only when the drawing is complete; the viewer will never see a partially drawn frame glutPostRedisplay() -- This will cause the display function to be involked again with the new variable.

10/15/ Display List A display list is a group of OpenGL commands only that have been stored for later execution. glNewList() -- specifies the start of a display list. The first parameter is a nonzero positive integer that uniquely identifies the display list created by glGenLists(). Two parameters can be put, GL_COMPILE_AND_EXECUTE and GL_COMPILE. glEndList() -- specifies the end of a display list. glCallList() – executes a display list.

10/15/ Thank You

10/15/

10/15/

10/15/

10/15/ Algorithm: Voronoi Hierarchy Construction 1. in 2D planar case 2. in 3D space case