Introduction to OpenGL. Prof. Dr.-Ing. Lars Linsen

Size: px
Start display at page:

Download "Introduction to OpenGL. Prof. Dr.-Ing. Lars Linsen"

Transcription

1 Introduction to OpenGL Prof. Dr.-Ing. Lars Linsen School of Engineering and Science Bremen : Advanced Visualization Lab

2 1. What is OpenGL?

3 Graphics Programming Graphical user interface (GUI) Windowing system X Integrated in OS: Microsoft Windows, Mac OS Microsoft Direct3D OpenGL (Open Graphics Library) OpenGL 2.0 (and higher) GLSL (GL Shading Language) Cg (nvidia) HLSL (high level shader language, DirectX) GPGPU programming: CUDA (nvidia), CTM (ATI), OpenCL : Advanced Visualization Lab 3

4 What is OpenGL? OpenGL is a software interface for 3D computer graphics Originally developed by SGI (IRIS GL) since 1992 under control of ARB (Architecture Review Board) OpenGL specification is hardware-independent, window system independent and operating system independent. Different implementations (as hardware and/or software) C library : Advanced Visualization Lab 4

5 OpenGL Architecture Polynomial Evaluator Per Vertex Operations & Primitive Assembly CPU Display List Rasterization Per Fragment Operations Frame Buffer Pixel Operations Texture Memory : Advanced Visualization Lab 5

6 OpenGL as a Renderer Geometric primitives points, lines, and polygons Image Primitives images and bitmaps Separate pipeline for images and geometry linked through texture mapping Rendering depends on state colors, materials, light sources, etc : Advanced Visualization Lab 6

7 Controlling current state Setting State glpointsize( size ); gllinestipple( repeat, pattern ); glshademodel( GL_SMOOTH ); Enabling Features glenable( GL_LIGHTING ); gldisable( GL_TEXTURE_2D ); : Advanced Visualization Lab 7

8 OpenGL Command Formats glvertex3fv( v ) Number of components 2 - (x,y) 3 - (x,y,z) 4 - (x,y,z,w) 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 glvertex2f( x, y ) : Advanced Visualization Lab 8

9 Related APIs AGL, GLX, WGL glue between OpenGL and windowing systems GLU (OpenGL Utility Library) part of OpenGL NURBS, tessellators, quadric shapes, etc. GLUT (OpenGL Utility Toolkit) portable windowing API not officially part of OpenGL : Advanced Visualization Lab 9

10 OpenGL and Related APIs application program OpenGL Motif widget or similar GLX, AGL or WGL X, Win32, Mac O/S GLUT GLU GL software and/or hardware : Advanced Visualization Lab 10

11 Preliminaries Headers Files #include <GL/gl.h> #include <GL/glu.h> #include <GL/glut.h> Libraries Enumerated Types OpenGL defines numerous types for compatibility GLfloat, GLint, GLenum, etc : Advanced Visualization Lab 11

12 2. Getting Started

13 Getting started with OpenGL Installation of Mesa3D: : Advanced Visualization Lab 13

14 Getting started with OpenGL Installation of Mesa3D: : Advanced Visualization Lab 14

15 Setting up GLUT To use GLUT its header file has to be included in the source: #include <GL/glut.h> The program has to be linked against the GLUT library For GCC just compile with -lglut For MSVC and other of the sort add glut to the libraries in the project options : Advanced Visualization Lab 15

16 GLUT Basics Application Structure Configure and open window Initialize OpenGL state Register input callback functions render resize input: keyboard, mouse, etc. Enter event processing loop : Advanced Visualization Lab 16

17 Initializing GLUT void glutinit(int argc, char **argv); Initializes GLUT library. Should be called before any other routine. Processes window system specific command line arguments. void glutinitdisplaymode(unsigned int mode); Sets the GLUT display mode for windows created with glutcreatewindow() The display mode is a bitwise or combination of GLUT_RGBA or GLUT_INDEX, GLUT_SINGLE or GLUT_DOUBLE, and any of the buffer-enabling flags GLUT_DEPTH, GLUT_STENCIL, or GLUT_ACCUM : Advanced Visualization Lab 17

18 Initializing GLUT void glutinitwindowsize(int width, int height); width and height of the window void glutinitwindowposition(int x, int y); Sets the coordinates of the top-left corner int glutcreatewindow(char *name); Creates a window with the name name and returns a unique window identifying integer (handle). Useful when rendering is done in multiple windows of the same application : Advanced Visualization Lab 18

19 Handling events with GLUT Callback functions are registered to the corresponding event, i.e., when the respective event takes place, the function is called to handle it. Window events: void glutdisplayfunc(void (*func)(void)); The function given as argument is called whenever the window has to be redrawn void glutreshapefunc(void (*func)(int width, int height)); The function is called when the window is resized. Width and height are the new width and height of the resized window. When no function is specified (NULL), a default one is assigned : Advanced Visualization Lab 19

20 Handling Events with GLUT Input events void glutkeyboardfunc(void (*func)(unsigned int key, int x, int y); The function is called when a key is pressed. Key is the ASCII of the pressed key, x and y are the mouse coordinates (window relative) at the moment the key is pressed void glutspecialfunc(void (*func)(int key, int x, int y)); Triggered when a special key is pressed (F1..F12, arrows, Insert, Home, etc.). void glutmousefunc(void (*func)(int button, int state, int x, int y)); Triggered when a mouse button is pressed or released. Button is left, right or middle, state is down or up, x and y are as above. void glutmotionfunc(void (*func)(int x, int y)); Specifies the function that is called when the mouse is moved while one or more buttons are pressed : Advanced Visualization Lab 20

21 Handling Events with GLUT Redisplaying void glutpostredisplay(void); Posts a message to the queue that redisplaying is required. At the first opportunity, the function is called. Idling void glutidlefunc(void (*func)(void)); Function is called when nothing is happening. Sometimes this function is set to the displaying function and timed to force a certain FPS : Advanced Visualization Lab 21

22 Running the Application Entering the process loop void glutmainloop(void); : Advanced Visualization Lab 22

23 First example: Main function (1) : Advanced Visualization Lab 23

24 Main function (2) : Advanced Visualization Lab 24

25 Reshape function : Advanced Visualization Lab 25

26 Keyboard function : Advanced Visualization Lab 26

27 Display function (1) : Advanced Visualization Lab 27

28 Display function (2) : Advanced Visualization Lab 28

29 Display function (3) : Advanced Visualization Lab 29

30 3. Viewing : Advanced Visualization Lab 30

31 Camera analogy 3D is just like taking a photograph (lots of photographs!) camera viewing volume tripod model : Advanced Visualization Lab 31

32 Camera analogy and transformations Projection transformations adjust the lens of the camera Viewing transformations tripod define position and orientation of the viewing volume in the world Modeling transformations moving the model Viewport transformations enlarge or reduce the physical photograph : Advanced Visualization Lab 32

33 Programming transformations Prior to rendering, view, locate, and orient: eye/camera position 3D geometry Manage the matrices including matrix stack Combine (composite) transformations : Advanced Visualization Lab 33

34 Transformation pipeline v e r t e x Modelview Matrix Projection Matrix CPU CPU Perspective Division Poly. Poly. object eye clip normalized device DL DL Pixel Pixel Per Per Vertex Vertex Texture Texture Raster Raster Viewport Transform Frag Frag window FB FB Modelview Modelview Projection other calculations here material color shade model (flat) polygon rendering mode polygon culling clipping : Advanced Visualization Lab 34

35 Coordinate systems and transformations Steps in forming an image specify geometry (world coordinates) specify camera (camera coordinates) project (window coordinates) map to viewport (screen coordinates) Each step uses transformations Every transformation is equivalent to a change in coordinate systems (frames) : Advanced Visualization Lab 35

36 Homogeneous coordinates each vertex is a column vector x y v r = z w w is usually 1.0 all operations are matrix multiplications directions (directed line segments) can be represented with w = : Advanced Visualization Lab 36

37 3D transformations A vertex is transformed by 4 x 4 matrices all affine operations are matrix multiplications all matrices are stored column-major in OpenGL matrices are always post-multiplied product of matrix and vector is Mv v M = m m m m m m m m m m m m m m m m : Advanced Visualization Lab 37

38 Specifying transformations Specify Current Matrix Stack glmatrixmode( GL_MODELVIEW or GL_PROJECTION ) Programmer has two styles of specifying transformations specify matrices (glloadmatrix, glmultmatrix) specify operation (gltranslate, glrotate,, glortho) : Advanced Visualization Lab 38

39 Projection Transformation Shape of viewing frustum Perspective projection gluperspective( fovy, aspect, znear, zfar ) glfrustum( left, right, bottom, top, znear, zfar ) Orthographic parallel projection glortho( left, right, bottom, top, znear, zfar ) gluortho2d( left, right, bottom, top ) calls glortho with z values near zero : Advanced Visualization Lab 39

40 Orthogonal projection void glortho(gldouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far); Creates a matrix for an orthographic parallel view and multiplies it by the current matrix : Advanced Visualization Lab 40

41 Applying projection transformations Typical use (orthographic projection) glmatrixmode( GL_PROJECTION ); glloadidentity(); glortho( left, right, bottom, top, znear, zfar ); : Advanced Visualization Lab 41

42 Perspective projection void glfrustum(gldouble left, Gldouble right, Gldouble bottom, Gldouble top, Gldouble near, Gldouble far); Creates a matrix for the frustrum and multiplies the current matrix by it. Near and far are the distances to the clipping planes : Advanced Visualization Lab 42

43 Perspective projection More intuitive: void gluperspective(gldouble fovy, Gldouble aspect, Gldouble near, Gldouble far); fovy is the field of view in x-z plane. Aspect is the aspect ratio width/height : Advanced Visualization Lab 43

44 Viewing transformations Position the camera/eye in the scene place the tripod down; aim camera To fly through a scene change viewing transformation and redraw scene glulookat( eye x, eye y, eye z, aim x, aim y, aim z, up x, up y, up z ) up vector determines unique orientation careful of degenerate positions tripod : Advanced Visualization Lab 44

45 Viewing transformation : Advanced Visualization Lab 45

46 Modeling transformations Move object gltranslate{fd}( x, y, z ) Rotate object around arbitrary axis glrotate{fd}( angle, x, y, z ) angle is in degrees Dilate (stretch or shrink) or mirror object glscale{fd}( x, y, z ) : Advanced Visualization Lab 46

47 Viewing and modeling Moving camera is equivalent to moving every object in the world towards a stationary camera Viewing transformations are equivalent to several modeling transformations : Advanced Visualization Lab 47

48 Viewport Transformations Viewport usually same as window size can be used to see part of the screen to which is rendered viewport aspect ratio should be same as projection transformation or resulting image may be distorted glviewport( x, y, width, height ) : Advanced Visualization Lab 48

49 Matrix Operations Specify Current Matrix Stack glmatrixmode( GL_MODELVIEW or GL_PROJECTION ) Other Matrix or Stack Operations glloadidentity() glpushmatrix() glpopmatrix() : Advanced Visualization Lab 49

50 Matrix stacks The matrices manipulated by all operations discussed so far are the ones that sit on the top of the matrix stack. When a matrix is pushed onto the stack, the current topmost matrix is duplicated, so that first and second matrices contain the same entries. When popping a matrix, the topmost matrix is deleted and the second one becomes the topmost one : Advanced Visualization Lab 50

51 Matrix stacks - some applications Modelview matrices E.g.: Save the current position, go somewhere else, draw something, return to the previous position, go elsewhere, draw the same thing scaled by a factor of 2, return to the initial position, The stack may contain at least 32 matrices (depends on the OpenGL implementation) Projection matrices E.g. useful when a text box needs to be displayed (since text is best viewed in orthogonal projection and realistic applications are using perspective projections). At least 2 matrices (again depends on implementation) : Advanced Visualization Lab 51

52 4. Object Representation

53 OPenGL primitive types Points: : Advanced Visualization Lab 53

54 OPenGL primitive types Line segments & sequences thereof: : Advanced Visualization Lab 54

55 OpenGL primitive types Convex simple polygons & meshes: : Advanced Visualization Lab 55

56 Using OpenGL primitives Primitives are specified using glbegin( primtype ); glend(); primtype is any of the primitive types and determines how vertices are combined. GLfloat red, green, blue; Glfloat coords[3]; glcolor3f( red, green, blue ); glbegin( primtype ); for ( i = 0; i < nverts; ++i ) { glvertex3fv( coords ); } glend(); : Advanced Visualization Lab 56

57 Using OpenGL Primitives : Advanced Visualization Lab 57

58 Using OpenGL Primitives glbegin(gl_polygon); glvertex2f(0.0, 0.0); glvertex2f(0.0, 3.0); glvertex2f(4.0, 3.0); glvertex2f(6.0, 1.5); glvertex2f(4.0, 0.0); glend(); : Advanced Visualization Lab 58

59 GLUT objects void glutwiresphere(gldouble radius, GLint slices, GLint stacks); void glutsolidsphere(gldouble radius, GLint slices, GLint stacks); void glutwirecube(gldouble size); void glutsolidcube(gldouble size); void glutwiretorus(gldouble innerradius, GLdouble outerradius, GLint nsides, GLint rings); void glutsolidtorus(gldouble innerradius, GLdouble outerradius, GLint nsides, GLint rings); : Advanced Visualization Lab 59

60 GLUT objects : Advanced Visualization Lab 60

61 GLUT objects : Advanced Visualization Lab 61

62 GLUT objects void glutwireicosahedron(void); void glutsolidicosahedron(void); void glutwireoctahedron(void); void glutsolidoctahedron(void); void glutwiretetrahedron(void); void glutsolidtetrahedron(void); void glutwiredodecahedron(gldouble radius); void glutsoliddodecahedron(gldouble radius); : Advanced Visualization Lab 62

63 GLUT objects void glutwirecone(gldouble radius, GLdouble height, GLint slices, GLint stacks); void glutsolidcone(gldouble radius, GLdouble height, GLint slices, GLint stacks); void glutwireteapot(gldouble size); void glutsolidteapot(gldouble size); : Advanced Visualization Lab 63

64 GLUT objects : Advanced Visualization Lab 64

65 5. Displaying

66 Rasterization Poly. Poly. Per Per Vertex Vertex CPU CPU DL DL Raster Raster Frag Frag FB FB Texture Texture Pixel Pixel : Advanced Visualization Lab 66

67 Double Buffering Front Buffer Back Buffer Display : Advanced Visualization Lab 67

68 Animation Using Double Buffering Request a double buffered color buffer glutinitdisplaymode( GLUT_RGB GLUT_DOUBLE ); Clear color buffer glclear( GL_COLOR_BUFFER_BIT ); Render scene Request swap of front and back buffers glutswapbuffers(); Repeat steps 2-4 for animation : Advanced Visualization Lab 68

69 An Updated Program Template (cont.) void drawscene( void ) { GLfloat vertices[] = { }; GLfloat colors[] = { }; glclear( GL_COLOR_BUFFER_BIT); glbegin( GL_TRIANGLE_STRIP ); /* calls to glcolor*() and glvertex*() */ glend(); glutswapbuffers(); } : Advanced Visualization Lab 69

70 Antialiasing Removing the Jaggies glenable( mode ) GL_POINT_SMOOTH GL_LINE_SMOOTH GL_POLYGON_SMOOTH alpha value computed by computing sub-pixel coverage available in both RGBA and colormap modes : Advanced Visualization Lab 70

71 Full Scene Antialiasing : Jittering the view Each time we move the viewer, the image shifts Different aliasing artifacts in each image Averaging images using accumulation buffer averages out these artifacts : Advanced Visualization Lab 71

72 Blending Combine pixels with what s in already in the framebuffer glblendfunc( src, dst ) v C r = src v C f + dst v C p Fragment (src) Framebuffer Pixel (dst) Blending Equation Blended Pixel : Advanced Visualization Lab 72

73 Accumulation Buffer operations glaccum( op, value ) within the accumulation buffer: GL_ADD, GL_MULT from read buffer: GL_ACCUM, GL_LOAD transfer back to write buffer: GL_RETURN glaccum(gl_accum, 0.5) multiplies each value in write buffer by 0.5 and adds to accumulation buffer : Advanced Visualization Lab 73

74 Accumulation Buffer Problems of compositing into color buffers limited color resolution clamping loss of accuracy Accumulation buffer acts as a floating point color buffer accumulate into accumulation buffer transfer results to frame buffer : Advanced Visualization Lab 74

75 Multi-pass Rendering Blending allows results from multiple drawing passes to be combined together enables more complex rendering algorithms Example of bump-mapping done with a multi-pass OpenGL algorithm : Advanced Visualization Lab 75

76 Depth Buffering Color Buffer Depth Buffer Display : Advanced Visualization Lab 76

77 Depth Buffering Using OpenGL Request a depth buffer glutinitdisplaymode( GLUT_RGB GLUT_DOUBLE GLUT_DEPTH ); Enable depth buffering glenable( GL_DEPTH_TEST ); Clear color and depth buffers glclear( GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT ); Render scene Swap color buffers : Advanced Visualization Lab 77

78 6. Colors & Shading

79 Specifying Geometric Primitives : Advanced Visualization Lab 79

80 How OpenGL Simulates Lights Phong lighting model Computed at vertices Lighting contributors Surface material properties Light properties Lighting model properties : Advanced Visualization Lab 80

81 Surface Normals Normals define how a surface reflects light glnormal3f( x, y, z ) Current normal is used to compute vertex s color Use unit normals for proper lighting scaling affects a normal s length glenable( GL_NORMALIZE ) or glenable( GL_RESCALE_NORMAL ) : Advanced Visualization Lab 81

82 Material Properties Define the surface properties of a primitive glmaterialfv( face, property, value ); GL_DIFFUSE GL_SPECULAR GL_AMBIENT GL_EMISSION GL_SHININESS Base color Highlight Color Low-light Color Glow Color Surface Smoothness separate materials for front and back : Advanced Visualization Lab 82

83 Light Properties gllightfv( light, property, value ); light specifies which light multiple lights, starting with GL_LIGHT0 glgetintegerv( GL_MAX_LIGHTS, &n ); properties colors position and type attenuation : Advanced Visualization Lab 83

84 Light Colors Light color properties GL_AMBIENT GL_DIFFUSE GL_SPECULAR : Advanced Visualization Lab 84

85 Types of Lights OpenGL supports two types of Lights Local (Point) light sources Infinite (Directional) light sources Type of light controlled by w coordinate w = 0 w 0 Infinite Light directed along Local Light positioned at ( x y z) ( ) x y z w w w : Advanced Visualization Lab 85

86 Attenuation Light attenuation decrease light intensity with distance GL_CONSTANT_ATTENUATION GL_LINEAR_ATTENUATION GL_QUADRATIC_ATTENUATION f i = k c + k l 1 d + k q d : Advanced Visualization Lab 86

87 Turning on the Lights Flip each light s switch glenable( GL_LIGHTn ); Turn on the power glenable( GL_LIGHTING ); : Advanced Visualization Lab 87

88 Light & Material : Advanced Visualization Lab 88

89 Advanced Lighting Features Spotlights localize lighting affects GL_SPOT_DIRECTION GL_SPOT_CUTOFF GL_SPOT_EXPONENT : Advanced Visualization Lab 89

90 Shading Setting State glshademodel( GL_SMOOTH GL_FLAT); : Advanced Visualization Lab 90

91 8. Textures : Advanced Visualization Lab 91

92 Texture Mapping Poly. Poly. Per Per Vertex Vertex CPU CPU DL DL Pixel Pixel Texture Texture Raster Raster Frag Frag FB FB Apply a 1D, 2D, or 3D image to geometric primitives : Advanced Visualization Lab 92

93 Texture Mapping and the OpenGL Pipeline Images and geometry flow through separate pipelines that join at the rasterizer complex textures do not affect geometric complexity vertices geometry pipeline rasterizer image pixel pipeline : Advanced Visualization Lab 93

94 Applying Textures Three steps specify texture read or generate image assign to texture enable texturing assign texture coordinates to vertices specify texture parameters wrapping, filtering : Advanced Visualization Lab 94

95 Texture Objects Like display lists for texture images one image per texture object may be shared by several graphics contexts Generate texture names glgentextures( n, *texids ); : Advanced Visualization Lab 95

96 Texture Objects (cont.) Create texture objects with texture data and state Bind textures before using glbindtexture( target, id ); : Advanced Visualization Lab 96

97 Specify Texture Image Define a texture image from an array of texels in CPU memory glteximage2d( target, level, components, w, h, border, format, type, *texels ); : Advanced Visualization Lab 97

98 Mapping a Texture Based on parametric texture coordinates gltexcoord*() specified at each vertex t 0, 1 Texture Space a 1, 1 Object Space (s, t) = (0.2, 0.8) A b 0, 0 1, 0 c s (0.4, 0.2) B C (0.8, 0.4) : Advanced Visualization Lab 98

99 Example // Loading a Texture, specifying properties glgentextures(1, &texname); glbindtexture(gl_texture_2d, texname); gltexparameteri(gl_texture_2d, GL_TEXTURE_WRAP_S, GL_REPEAT); gltexparameteri(gl_texture_2d, GL_TEXTURE_WRAP_T, GL_REPEAT); glteximage2d(gl_texture_2d, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, Image_Buffer); // later while describing polygons... gltexcoord2f(0.0, 0.0); glvertex3f(-2.0, -1.0, 0.0); gltexcoord2f(0.0, 1.0); glvertex3f(-2.0, 1.0, 0.0); : Advanced Visualization Lab 99

100 Example : Advanced Visualization Lab 100

101 Applying Textures specify textures in texture objects set texture filter set texture function set texture wrap mode set optional perspective correction hint bind texture object enable texturing supply texture coordinates for vertex coordinates can also be generated : Advanced Visualization Lab 101

102 Texture Application Methods Filter Modes minification or magnification special mipmap minification filters Wrap Modes clamping or repeating (tiling) Texture Functions how to mix primitive s color with texture s color blend, modulate or replace texels : Advanced Visualization Lab 102

103 Filter Modes Example: gltexparameteri( target, type, mode ); Texture Polygon Magnification Texture Polygon Minification : Advanced Visualization Lab 103

104 Mipmapped Textures Mipmap allows for prefiltered texture maps of decreasing resolutions Lessens interpolation errors for smaller textured objects Declare mipmap level during texture definition glteximage*d( GL_TEXTURE_*D, level, ) GLU mipmap builder routines glubuild*dmipmaps( ) OpenGL 1.2 introduces advanced LOD controls : Advanced Visualization Lab 104

105 Wrapping Mode Example: gltexparameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ) gltexparameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ) t texture s GL_REPEAT wrapping GL_CLAMP wrapping : Advanced Visualization Lab 105

106 Texture Functions Controls how texture is applied gltexenv{fi}[v]( GL_TEXTURE_ENV, prop, param ) GL_TEXTURE_ENV_MODE modes GL_MODULATE GL_BLEND GL_REPLACE Set blend color with GL_TEXTURE_ENV_COLOR : Advanced Visualization Lab 106

107 Perspective Correction Hint Texture coordinate and color interpolation either linearly in screen space or using depth/perspective values (slower) Noticeable for polygons on edge glhint( GL_PERSPECTIVE_CORRECTION_HINT, hint ) where hint is one of GL_DONT_CARE GL_NICEST GL_FASTEST : Advanced Visualization Lab 107

108 Done.

Lecture 4 of 41. Lab 1a: OpenGL Basics

Lecture 4 of 41. Lab 1a: OpenGL Basics Lab 1a: OpenGL Basics William H. Hsu Department of Computing and Information Sciences, KSU KSOL course pages: http://snipurl.com/1y5gc Course web site: http://www.kddresearch.org/courses/cis636 Instructor

More information

ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO EECS 104. Fundamentals of Computer Graphics. OpenGL

ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO EECS 104. Fundamentals of Computer Graphics. OpenGL ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO SANTA BARBARA SANTA CRUZ EECS 104 Fundamentals of Computer Graphics OpenGL Slides courtesy of Dave Shreine, Ed Angel and Vicki Shreiner

More information

CS335 Graphics and Multimedia. Slides adopted from OpenGL Tutorial

CS335 Graphics and Multimedia. Slides adopted from OpenGL Tutorial CS335 Graphics and Multimedia Slides adopted from OpenGL Tutorial Texture Poly. Per Vertex Mapping CPU DL Texture Raster Frag FB Pixel Apply a 1D, 2D, or 3D image to geometric primitives Uses of Texturing

More information

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science CSC 307 1.0 Graphics Programming Department of Statistics and Computer Science Graphics Programming Texture Mapping 2 Texture Poly. Per Vertex Mapping CPU DL Pixel Texture Raster Frag FB Apply a 1D, 2D,

More information

Computer Graphics. Bing-Yu Chen National Taiwan University

Computer Graphics. Bing-Yu Chen National Taiwan University Computer Graphics Bing-Yu Chen National Taiwan University Introduction to OpenGL General OpenGL Introduction An Example OpenGL Program Drawing with OpenGL Transformations Animation and Depth Buffering

More information

API for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3

API for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3 OpenGL Introduction Introduction OpenGL OpenGL is an API for computer graphics. Hardware-independent Windowing or getting input is not included in the API Low-level Only knows about triangles (kind of,

More information

Computer Graphics. Bing-Yu Chen National Taiwan University

Computer Graphics. Bing-Yu Chen National Taiwan University Computer Graphics Bing-Yu Chen National Taiwan University Introduction to OpenGL General OpenGL Introduction An Example OpenGL Program Drawing with OpenGL Transformations Animation and Depth Buffering

More information

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW OpenGL Syntax Functions have prefix gl and initial capital letters for each word glclearcolor(), glenable(), glpushmatrix() glu for GLU functions glulookat(), gluperspective() constants begin with GL_,

More information

Lecture 2 2D transformations Introduction to OpenGL

Lecture 2 2D transformations Introduction to OpenGL Lecture 2 2D transformations Introduction to OpenGL OpenGL where it fits what it contains how you work with it OpenGL parts: GL = Graphics Library (core lib) GLU = GL Utilities (always present) GLX, AGL,

More information

OpenGL. Jimmy Johansson Norrköping Visualization and Interaction Studio Linköping University

OpenGL. Jimmy Johansson Norrköping Visualization and Interaction Studio Linköping University OpenGL Jimmy Johansson Norrköping Visualization and Interaction Studio Linköping University Background Software interface to graphics hardware 250+ commands Objects (models) are built from geometric primitives

More information

Introduction to OpenGL

Introduction to OpenGL Introduction to OpenGL Tutorial 1: Create a window and draw a 2D square Introduction: The aim of the first tutorial is to introduce you to the magic world of graphics based on the OpenGL and GLUT APIs.

More information

Exercise 1 Introduction to OpenGL

Exercise 1 Introduction to OpenGL Exercise 1 Introduction to OpenGL What we are going to do OpenGL Glut Small Example using OpenGl and Glut Alexandra Junghans 2 What is OpenGL? OpenGL Two Parts most widely used and supported graphics API

More information

Computer Graphics Course 2005

Computer Graphics Course 2005 Computer Graphics Course 2005 Introduction to GLUT, GLU and OpenGL Administrative Stuff Teaching Assistant: Rony Goldenthal Reception Hour: Wed. 18:00 19:00 Room 31 (Ross 1) Questions: E-mail: cg@cs Newsgroups:

More information

OpenGL refresher. Advanced Computer Graphics 2012

OpenGL refresher. Advanced Computer Graphics 2012 Advanced Computer Graphics 2012 What you will see today Outline General OpenGL introduction Setting up: GLUT and GLEW Elementary rendering Transformations in OpenGL Texture mapping Programmable shading

More information

An Interactive Introduction to OpenGL Programming

An Interactive Introduction to OpenGL Programming An Interactive Introduction to OpenGL Programming Course # 29 Dave Shreiner Ed Angel Vicki Shreiner Table of Contents Introduction...iv Prerequisites...iv Topics...iv Presentation Course Notes...vi An

More information

CS212. OpenGL Texture Mapping and Related

CS212. OpenGL Texture Mapping and Related CS212 OpenGL Texture Mapping and Related Basic Strategy Three steps to applying a texture 1. specify the texture read or generate image assign to texture enable texturing 2. assign texture coordinates

More information

Lecture 4 Advanced Computer Graphics (CS & SE )

Lecture 4 Advanced Computer Graphics (CS & SE ) Lecture 4 Advanced Computer Graphics (CS & SE 233.420) Topics Covered Animation Matrices Viewing Lighting Animating Interactive Programs Consider planet.c Want to animate rotating the Earth around the

More information

An Interactive Introduction to OpenGL and OpenGL ES Programming. Ed Angel Dave Shreiner

An Interactive Introduction to OpenGL and OpenGL ES Programming. Ed Angel Dave Shreiner An Interactive Introduction to OpenGL and OpenGL ES Programming Ed Angel Dave Shreiner Welcome This morning s Goals and Agenda Describe the OpenGL APIs and their uses Demonstrate and describe OpenGL s

More information

Computer Graphics 1 Computer Graphics 1

Computer Graphics 1 Computer Graphics 1 Projects: an example Developed by Nate Robbins Shapes Tutorial What is OpenGL? Graphics rendering API high-quality color images composed of geometric and image primitives window system independent operating

More information

VR-programming tools (procedural) More VRML later in this course! (declarative)

VR-programming tools (procedural) More VRML later in this course! (declarative) Realtime 3D Computer Graphics & Virtual Reality OpenGL Introduction VR-programming Input and display devices are the main hardware interface to users Immersion embeds users through the generation of live-like

More information

Computer Graphics. Bing-Yu Chen National Taiwan University

Computer Graphics. Bing-Yu Chen National Taiwan University Computer Graphics Bing-Yu Chen National Taiwan University Introduction to OpenGL General OpenGL Introduction An Example OpenGL Program Drawing with OpenGL Transformations Animation and Depth Buffering

More information

Precept 2 Aleksey Boyko February 18, 2011

Precept 2 Aleksey Boyko February 18, 2011 Precept 2 Aleksey Boyko February 18, 2011 Getting started Initialization Drawing Transformations Cameras Animation Input Keyboard Mouse Joystick? Textures Lights Programmable pipeline elements (shaders)

More information

Imaging and Raster Primitives

Imaging and Raster Primitives Realtime 3D Computer Graphics & Virtual Reality Bitmaps and Textures Imaging and Raster Primitives Vicki Shreiner Imaging and Raster Primitives Describe OpenGL s raster primitives: bitmaps and image rectangles

More information

Lecture 2. Determinants. Ax = 0. a 11 x 1 + a 12 x a 1n x n = 0 a 21 x 1 + a 22 x a 2n x n = 0

Lecture 2. Determinants. Ax = 0. a 11 x 1 + a 12 x a 1n x n = 0 a 21 x 1 + a 22 x a 2n x n = 0 A = a 11 a 12... a 1n a 21 a 22... a 2n. a n1 a n2... a nn x = x 1 x 2. x n Lecture 2 Math Review 2 Introduction to OpenGL Ax = 0 a 11 x 1 + a 12 x 2 +... + a 1n x n = 0 a 21 x 1 + a 22 x 2 +... + a 2n

More information

Lecture 07: Buffers and Textures

Lecture 07: Buffers and Textures Lecture 07: Buffers and Textures CSE 40166 Computer Graphics Peter Bui University of Notre Dame, IN, USA October 26, 2010 OpenGL Pipeline Today s Focus Pixel Buffers: read and write image data to and from

More information

3D Graphics and API with OpenGL

3D Graphics and API with OpenGL 3D Graphics and API with OpenGL Human-Centered CAD Lab. 29-3-3 Contents 3D Graphics API & OpenGL Interactive Computer Graphics Example of OpenGL Programming Preparatory Simple code GLUT Functions Transformation

More information

Objectives. Texture Mapping and NURBS Week 7. The Limits of Geometric Modeling. Modeling an Orange. Three Types of Mapping. Modeling an Orange (2)

Objectives. Texture Mapping and NURBS Week 7. The Limits of Geometric Modeling. Modeling an Orange. Three Types of Mapping. Modeling an Orange (2) CS 480/680 INTERACTIVE COMPUTER GRAPHICS Texture Mapping and NURBS Week 7 David Breen Department of Computer Science Drexel University Objectives Introduce Mapping Methods Texture Mapping Environmental

More information

Introduction to Computer Graphics with OpenGL/GLUT

Introduction to Computer Graphics with OpenGL/GLUT Introduction to Computer Graphics with OpenGL/GLUT What is OpenGL? A software interface to graphics hardware Graphics rendering API (Low Level) High-quality color images composed of geometric and image

More information

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations #include int main(int argc, char** argv) { glutinit(&argc, argv); Typical OpenGL/GLUT Main Program // GLUT, GLU, and OpenGL defs // program arguments // initialize glut and gl // double buffering

More information

Computer graphics MN1

Computer graphics MN1 Computer graphics MN1 http://www.opengl.org Todays lecture What is OpenGL? How do I use it? Rendering pipeline Points, vertices, lines,, polygons Matrices and transformations Lighting and shading Code

More information

Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D

Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D CS334 Spring 2012 Daniel G. Aliaga Department of Computer Science Purdue University Computer Graphics Pipeline Geometric Primitives

More information

Computer graphic -- Programming with OpenGL 2

Computer graphic -- Programming with OpenGL 2 Computer graphic -- Programming with OpenGL 2 OpenGL OpenGL (Open Graphics Library) a cross-language, multi-platform API for rendering 2D and 3D computer graphics. The API is typically used to interact

More information

Most device that are used to produce images are. dots (pixels) to display the image. This includes CRT monitors, LCDs, laser and dot-matrix

Most device that are used to produce images are. dots (pixels) to display the image. This includes CRT monitors, LCDs, laser and dot-matrix Scan Conversion of Lines Raster devices Most device that are used to produce images are raster devices, that is, use rectangular arrays of dots (pixels) to display the image. This includes CRT monitors,

More information

OpenGL. Toolkits.

OpenGL. Toolkits. http://www.opengl.org OpenGL Open Graphics Library Graphics API Delivered with UNIX, Win9x/2000/Me/Nt/Xp, Mac OS Direct3D (DirectX) is only Windows Utilizes the window system and event handling of the

More information

Lectures OpenGL Introduction

Lectures OpenGL Introduction Lectures OpenGL Introduction By Tom Duff Pixar Animation Studios Emeryville, California and George Ledin Jr Sonoma State University Rohnert Park, California 2004, Tom Duff and George Ledin Jr 1 What is

More information

Lecture 2 CISC440/640 Spring Department of Computer and Information Science

Lecture 2 CISC440/640 Spring Department of Computer and Information Science Lecture 2 CISC440/640 Spring 2015 Department of Computer and Information Science Today s Topic The secrets of Glut-tony 2 So let s do some graphics! For the next week or so this is your world: -1 1-1 1

More information

Getting Started. Overview (1): Getting Started (1): Getting Started (2): Getting Started (3): COSC 4431/5331 Computer Graphics.

Getting Started. Overview (1): Getting Started (1): Getting Started (2): Getting Started (3): COSC 4431/5331 Computer Graphics. Overview (1): Getting Started Setting up OpenGL/GLUT on Windows/Visual Studio COSC 4431/5331 Computer Graphics Thursday January 22, 2004 Overview Introduction Camera analogy Matrix operations and OpenGL

More information

Image Rendering. Rendering can be divided into three sub-problems. Image Formation The hidden surface problem visibility determination steps

Image Rendering. Rendering can be divided into three sub-problems. Image Formation The hidden surface problem visibility determination steps Image Rendering Rendering can be divided into three sub-problems Image Formation The hidden surface problem visibility determination steps Illumination Direct illumination Indirect illumination Shading

More information

Graphics Pipeline & APIs

Graphics Pipeline & APIs Graphics Pipeline & APIs CPU Vertex Processing Rasterization Fragment Processing glclear (GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT); glpushmatrix (); gltranslatef (-0.15, -0.15, solidz); glmaterialfv(gl_front,

More information

RECITATION - 1. Ceng477 Fall

RECITATION - 1. Ceng477 Fall RECITATION - 1 Ceng477 Fall 2007-2008 2/ 53 Agenda General rules for the course General info on the libraries GLUT OpenGL GLUI Details about GLUT Functions Probably we will not cover this part 3/ 53 General

More information

Introduction to OpenGL

Introduction to OpenGL Introduction to OpenGL Banafsheh Azari http://www.uni-weimar.de/cms/medien/cg.html What You ll See Today What is OpenGL? Related Libraries OpenGL Command Syntax B. Azari http://www.uni-weimar.de/cms/medien/cg.html

More information

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3) Computer Graphics (Fall 2008) COMS 4160, Lecture 9: OpenGL 1 http://www.cs.columbia.edu/~cs4160 To Do Start thinking (now) about HW 3. Milestones are due soon. Course Course 3D Graphics Pipeline 3D Graphics

More information

CS 4204 Computer Graphics

CS 4204 Computer Graphics CS 4204 Computer Graphics OpenGL Basics Yong Cao Virginia Tech References: 2001 Siggraph, An Interactive Introduction to OpenGL Programming, Dave Shreiner,Ed Angel, Vicki Shreiner Official Presentation

More information

Graphics. Texture Mapping 고려대학교컴퓨터그래픽스연구실.

Graphics. Texture Mapping 고려대학교컴퓨터그래픽스연구실. Graphics Texture Mapping 고려대학교컴퓨터그래픽스연구실 3D Rendering Pipeline 3D Primitives 3D Modeling Coordinates Model Transformation 3D World Coordinates Lighting 3D World Coordinates Viewing Transformation 3D Viewing

More information

Computer Graphics. Bing-Yu Chen National Taiwan University

Computer Graphics. Bing-Yu Chen National Taiwan University Computer Graphics Bing-Yu Chen National Taiwan University Introduction to OpenGL General OpenGL Introduction An Example OpenGL Program Drawing with OpenGL Transformations Animation and Depth Buffering

More information

Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt

Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt CS334 Fall 2015 Daniel G. Aliaga Department of Computer Science Purdue University Books (and by now means complete ) Interactive Computer

More information

Graphics Pipeline & APIs

Graphics Pipeline & APIs 3 2 4 Graphics Pipeline & APIs CPU Vertex Processing Rasterization Processing glclear (GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT); glpushmatrix (); gltranslatef (-0.15, -0.15, solidz); glmaterialfv(gl_front,

More information

Introduction to OpenGL

Introduction to OpenGL CS100433 Introduction to OpenGL Junqiao Zhao 赵君峤 Department of Computer Science and Technology College of Electronics and Information Engineering Tongji University Before OpenGL Let s think what is need

More information

CS559: Computer Graphics. Lecture 12: OpenGL Li Zhang Spring 2008

CS559: Computer Graphics. Lecture 12: OpenGL Li Zhang Spring 2008 CS559: Computer Graphics Lecture 12: OpenGL Li Zhang Spring 2008 Reading Redbook Ch 1 & 2 So far: 3D Geometry Pipeline Model Space (Object Space) Rotation Translation Resizing World Space M Rotation Translation

More information

Computer Graphics. Three-Dimensional Graphics VI. Guoying Zhao 1 / 73

Computer Graphics. Three-Dimensional Graphics VI. Guoying Zhao 1 / 73 Computer Graphics Three-Dimensional Graphics VI Guoying Zhao 1 / 73 Texture mapping Guoying Zhao 2 / 73 Objectives Introduce Mapping Methods Texture Mapping Environment Mapping Bump Mapping Consider basic

More information

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL Today s Agenda Basic design of a graphics system Introduction to OpenGL Image Compositing Compositing one image over another is most common choice can think of each image drawn on a transparent plastic

More information

OpenGL Texture Mapping. Objectives Introduce the OpenGL texture functions and options

OpenGL Texture Mapping. Objectives Introduce the OpenGL texture functions and options OpenGL Texture Mapping Objectives Introduce the OpenGL texture functions and options 1 Basic Strategy Three steps to applying a texture 1. 2. 3. specify the texture read or generate image assign to texture

More information

1 (Practice 1) Introduction to OpenGL

1 (Practice 1) Introduction to OpenGL 1 (Practice 1) Introduction to OpenGL This first practical is intended to get you used to OpenGL command. It is mostly a copy/paste work. Try to do it smartly by tweaking and messing around with parameters,

More information

CSE 167: Introduction to Computer Graphics Lecture #5: Visibility, OpenGL

CSE 167: Introduction to Computer Graphics Lecture #5: Visibility, OpenGL CSE 167: Introduction to Computer Graphics Lecture #5: Visibility, OpenGL Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016 Announcements Tomorrow: assignment 1 due Grading

More information

Outline. Other Graphics Technology. OpenGL Background and History. Platform Specifics. The Drawing Process

Outline. Other Graphics Technology. OpenGL Background and History. Platform Specifics. The Drawing Process Outline 433-380 Graphics and Computation Introduction to OpenGL OpenGL Background and History Other Graphics Technology Drawing Viewing and Transformation Lighting GLUT Resources Some images in these slides

More information

Graphics and Computation Introduction to OpenGL

Graphics and Computation Introduction to OpenGL 433-380 Graphics and Computation Introduction to OpenGL Some images in these slides are taken from The OpenGL Programming Manual, which is copyright Addison Wesley and the OpenGL Architecture Review Board.

More information

Computer Graphics Programming

Computer Graphics Programming Computer Graphics Programming Graphics APIs Using MFC (Microsoft Foundation Class) in Visual C++ Programming in Visual C++ GLUT in Windows and Unix platform Overview and Application Graphics APIs Provide

More information

OpenGL/GLUT Intro. Week 1, Fri Jan 12

OpenGL/GLUT Intro. Week 1, Fri Jan 12 University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner OpenGL/GLUT Intro Week 1, Fri Jan 12 http://www.ugrad.cs.ubc.ca/~cs314/vjan2007 News Labs start next week Reminder:

More information

Introduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou

Introduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou Introduction to OpenGL Transformations, Viewing and Lighting Ali Bigdelou Modeling From Points to Polygonal Objects Vertices (points) are positioned in the virtual 3D scene Connect points to form polygons

More information

Texture Mapping. Mike Bailey.

Texture Mapping. Mike Bailey. Texture Mapping 1 Mike Bailey mjb@cs.oregonstate.edu This work is licensed under a Creative Commons Attribution-NonCommercial- NoDerivatives 4.0 International License TextureMapping.pptx The Basic Idea

More information

An Interactive Introduction to OpenGL Programming. An Interactive Introduction to OpenGL Programming. SIGGRAPH New Orleans 1

An Interactive Introduction to OpenGL Programming. An Interactive Introduction to OpenGL Programming. SIGGRAPH New Orleans 1 What You ll See Today OpenGL and GLUT Overview What Is OpenGL? An Interactive Introduction to OpenGL Dave Shreiner Ed Angel General OpenGL Introduction Rendering Primitives Rendering Modes Lighting Mapping

More information

OpenGL Transformations

OpenGL Transformations OpenGL Transformations R. J. Renka Department of Computer Science & Engineering University of North Texas 02/18/2014 Introduction The most essential aspect of OpenGL is the vertex pipeline described in

More information

Basic Graphics Programming

Basic Graphics Programming CSCI 480 Computer Graphics Lecture 2 Basic Graphics Programming January 11, 2012 Jernej Barbic University of Southern California http://www-bcf.usc.edu/~jbarbic/cs480-s12/ Graphics Pipeline OpenGL API

More information

Rendering. Part 1 An introduction to OpenGL

Rendering. Part 1 An introduction to OpenGL Rendering Part 1 An introduction to OpenGL Olivier Gourmel VORTEX Team IRIT University of Toulouse gourmel@irit.fr Image synthesis The Graphics Processing Unit (GPU): A highly parallel architecture specialized

More information

Programming using OpenGL: A first Introduction

Programming using OpenGL: A first Introduction Programming using OpenGL: A first Introduction CMPT 361 Introduction to Computer Graphics Torsten Möller Machiraju/Zhang/Möller 1 Today Overview GL, GLU, GLUT, and GLUI First example OpenGL functions and

More information

Computer Graphics (Basic OpenGL)

Computer Graphics (Basic OpenGL) Computer Graphics (Basic OpenGL) Thilo Kielmann Fall 2008 Vrije Universiteit, Amsterdam kielmann@cs.vu.nl http://www.cs.vu.nl/ graphics/ Computer Graphics (Basic OpenGL, Input and Interaction), ((57))

More information

OpenGL. 1 OpenGL OpenGL 1.2 3D. (euske) 1. Client-Server Model OpenGL

OpenGL. 1 OpenGL OpenGL 1.2 3D. (euske) 1. Client-Server Model OpenGL OpenGL (euske) 1 OpenGL - 1.1 OpenGL 1. Client-Server Model 2. 3. 1.2 3D OpenGL (Depth-Buffer Algorithm Z-Buffer Algorithm) (polygon ) ( rendering) Client-Server Model X Window System ( GL ) GL (Indy O

More information

Introduction to OpenGL Week 1

Introduction to OpenGL Week 1 CS 432/680 INTERACTIVE COMPUTER GRAPHICS Introduction to OpenGL Week 1 David Breen Department of Computer Science Drexel University Based on material from Ed Angel, University of New Mexico Objectives

More information

Objectives. Image Formation Revisited. Physical Approaches. The Programmer s Interface. Practical Approach. Introduction to OpenGL Week 1

Objectives. Image Formation Revisited. Physical Approaches. The Programmer s Interface. Practical Approach. Introduction to OpenGL Week 1 CS 432/680 INTERACTIVE COMPUTER GRAPHICS Introduction to OpenGL Week 1 David Breen Department of Computer Science Drexel University Objectives Learn the basic design of a graphics system Introduce graphics

More information

4 Introduction to OpenGL Programming. Chapter 4. Introduction to OpenGL Programming. Department of Computer Science and Engineering 4-1

4 Introduction to OpenGL Programming. Chapter 4. Introduction to OpenGL Programming. Department of Computer Science and Engineering 4-1 Chapter 4 Introduction to OpenGL Programming 4-1 Overview This chapter is supposed to provide a brief overview of some of the most important features of OpenGL. It will include details that go beyond the

More information

11/1/13. Basic Graphics Programming. Teaching Assistant. What is OpenGL. Course Producer. Where is OpenGL used. Graphics library (API)

11/1/13. Basic Graphics Programming. Teaching Assistant. What is OpenGL. Course Producer. Where is OpenGL used. Graphics library (API) CSCI 420 Computer Graphics Lecture 2 Basic Graphics Programming Teaching Assistant Yijing Li Office hours TBA Jernej Barbic University of Southern California Graphics Pipeline OpenGL API Primitives: Lines,

More information

Computer Graphics Lighting

Computer Graphics Lighting Lighting 1 Mike Bailey mjb@cs.oregonstate.edu This work is licensed under a Creative Commons Attribution-NonCommercial- NoDerivatives 4.0 International License Lighting.pptx Why Do We Care About Lighting?

More information

Computer Graphics Lighting. Why Do We Care About Lighting?

Computer Graphics Lighting. Why Do We Care About Lighting? Lighting 1 Mike Bailey mjb@cs.oregonstate.edu This work is licensed under a Creative Commons Attribution-NonCommercial- NoDerivatives 4.0 International License Lighting.pptx Why Do We Care About Lighting?

More information

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches: Surface Graphics Objects are explicitely defined by a surface or boundary representation (explicit inside vs outside) This boundary representation can be given by: - a mesh of polygons: 200 polys 1,000

More information

OpenGL Tutorial. Ceng 477 Introduction to Computer Graphics

OpenGL Tutorial. Ceng 477 Introduction to Computer Graphics OpenGL Tutorial Ceng 477 Introduction to Computer Graphics Adapted from: http://www.cs.princeton.edu/courses/archive/spr06/cos426/assn3/opengl_tutorial.ppt OpenGL IS an API OpenGL IS nothing more than

More information

Basic Graphics Programming

Basic Graphics Programming 15-462 Computer Graphics I Lecture 2 Basic Graphics Programming Graphics Pipeline OpenGL API Primitives: Lines, Polygons Attributes: Color Example January 17, 2002 [Angel Ch. 2] Frank Pfenning Carnegie

More information

Scan line algorithm. Jacobs University Visualization and Computer Graphics Lab : Graphics and Visualization 272

Scan line algorithm. Jacobs University Visualization and Computer Graphics Lab : Graphics and Visualization 272 Scan line algorithm The scan line algorithm is an alternative to the seed fill algorithm. It does not require scan conversion of the edges before filling the polygons It can be applied simultaneously to

More information

Textures. Texture Mapping. Bitmap Textures. Basic Texture Techniques

Textures. Texture Mapping. Bitmap Textures. Basic Texture Techniques Texture Mapping Textures The realism of an image is greatly enhanced by adding surface textures to the various faces of a mesh object. In part a) images have been pasted onto each face of a box. Part b)

More information

Lecture 19: OpenGL Texture Mapping. CITS3003 Graphics & Animation

Lecture 19: OpenGL Texture Mapping. CITS3003 Graphics & Animation Lecture 19: OpenGL Texture Mapping CITS3003 Graphics & Animation E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 Objectives Introduce the OpenGL texture functions and options

More information

OpenGL: A Practical Introduction. (thanks, Mark Livingston!)

OpenGL: A Practical Introduction. (thanks, Mark Livingston!) OpenGL: A Practical Introduction (thanks, Mark Livingston!) Outline What is OpenGL? Auxiliary libraries Basic code structure Rendering Practical hints Virtual world operations OpenGL Definitions Software

More information

UNIT 7 LIGHTING AND SHADING. 1. Explain phong lighting model. Indicate the advantages and disadvantages. (Jun2012) 10M

UNIT 7 LIGHTING AND SHADING. 1. Explain phong lighting model. Indicate the advantages and disadvantages. (Jun2012) 10M UNIT 7 LIGHTING AND SHADING 1. Explain phong lighting model. Indicate the advantages and disadvantages. (Jun2012) 10M Ans: Phong developed a simple model that can be computed rapidly It considers three

More information

Lighting and Texturing

Lighting and Texturing Lighting and Texturing Michael Tao Michael Tao Lighting and Texturing 1 / 1 Fixed Function OpenGL Lighting Need to enable lighting Need to configure lights Need to configure triangle material properties

More information

Modeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益

Modeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益 Modeling Transform Chapter 4 Geometric Transformations 李同益 Specify transformation for objects Allow definitions of objects in own coordinate systems Allow use of object definition multiple times in a scene

More information

CHAPTER 1 Graphics Systems and Models 3

CHAPTER 1 Graphics Systems and Models 3 ?????? 1 CHAPTER 1 Graphics Systems and Models 3 1.1 Applications of Computer Graphics 4 1.1.1 Display of Information............. 4 1.1.2 Design.................... 5 1.1.3 Simulation and Animation...........

More information

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

GRAFIKA KOMPUTER. ~ M. Ali Fauzi GRAFIKA KOMPUTER ~ M. Ali Fauzi Texture Mapping WHY TEXTURE? Imagine a Chess Floor Or a Brick Wall How to Draw? If you want to draw a chess floor, each tile must be drawn as a separate quad. A large flat

More information

COMP 371/4 Computer Graphics Week 1

COMP 371/4 Computer Graphics Week 1 COMP 371/4 Computer Graphics Week 1 Course Overview Introduction to Computer Graphics: Definition, History, Graphics Pipeline, and Starting Your First OpenGL Program Ack: Slides from Prof. Fevens, Concordia

More information

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science CSC 307 1.0 Graphics Programming Department of Statistics and Computer Science Graphics Programming 2 Common Uses for Computer Graphics Applications for real-time 3D graphics range from interactive games

More information

Texture Mapping and Sampling

Texture Mapping and Sampling Texture Mapping and Sampling CPSC 314 Wolfgang Heidrich The Rendering Pipeline Geometry Processing Geometry Database Model/View Transform. Lighting Perspective Transform. Clipping Scan Conversion Depth

More information

Graphics Programming

Graphics Programming Graphics Programming 3 rd Week, 2011 OpenGL API (1) API (application programming interface) Interface between an application program and a graphics system Application Program OpenGL API Graphics Library

More information

Computer Graphics, Chapt 08

Computer Graphics, Chapt 08 Computer Graphics, Chapt 08 Creating an Image Components, parts of a scene to be displayed Trees, terrain Furniture, walls Store fronts and street scenes Atoms and molecules Stars and galaxies Describe

More information

E.Order of Operations

E.Order of Operations Appendix E E.Order of Operations This book describes all the performed between initial specification of vertices and final writing of fragments into the framebuffer. The chapters of this book are arranged

More information

TNCG14 Advanced Computer Graphics Programming 1. OpenGL

TNCG14 Advanced Computer Graphics Programming 1. OpenGL March 19, 2010 1 Introduction This is a quick introduction to OpenGL with corresponding lab assignments. The example code can be downloaded from the lab section of the course homepage: http://staffwww.itn.liu.se/

More information

cs123 Lab 3 OpenGL Part One 1 Introduction 2 OpenGL Basics 2.2 The Rendering Pipeline 2.1 The CPU and the GPU 2.3 Basic Syntax of OpenGL commands

cs123 Lab 3 OpenGL Part One 1 Introduction 2 OpenGL Basics 2.2 The Rendering Pipeline 2.1 The CPU and the GPU 2.3 Basic Syntax of OpenGL commands cs123 Lab 3 OpenGL Part One Introduction to Computer Graphics 1 Introduction From now on, our weekly labs will focus on the use of OpenGL. While the lectures and projects will let you get a deeper understanding

More information

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Computer Graphics. Chapter 10 Three-Dimensional Viewing Computer Graphics Chapter 10 Three-Dimensional Viewing Chapter 10 Three-Dimensional Viewing Part I. Overview of 3D Viewing Concept 3D Viewing Pipeline vs. OpenGL Pipeline 3D Viewing-Coordinate Parameters

More information

Introduction to OpenGL

Introduction to OpenGL OpenGL is an alternative to Direct3D for 3D graphics rendering Originally developed by Silicon Graphics Inc (SGI), turned over to multi-vendor group (OpenGL Architecture Review Board) in 1992 Unlike DirectX,

More information

5HDOLVP7KURXJK6\QWKHVLV

5HDOLVP7KURXJK6\QWKHVLV &,6 '5DVWHU*UDSKLFV 5HDOLVP7KURXJK6\QWKHVLV Roger Crawfis Ohio State University 3OD\*DPHV«*RDOVRI&RPSXWHU*UDSKLFV *HQHUDWHV\QWKHWLFLPDJHVWKDWORRNUHDO 'RLWLQDSUDFWLFDOZD\DQGVFLHQWLILFDOO\ VRXQG,QUHDOWLPHREYLRXVO\$QGPDNHLWORRNHDV\«

More information

Computer Graphics. OpenGL

Computer Graphics. OpenGL Computer Graphics OpenGL What is OpenGL? OpenGL (Open Graphics Library) is a library for computer graphics It consists of several procedures and functions that allow a programmer to specify the objects

More information

An Overview GLUT GLSL GLEW

An Overview GLUT GLSL GLEW OpenGL, GLUT, GLEW, GLSL An Overview GLUT GLEW GLSL Objectives Give you an overview of the software that you will be using this semester OpenGL, GLUT, GLEW, GLSL What are they? How do you use them? What

More information

OpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL

OpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL OpenGL: Open Graphics Library Introduction to OpenGL Part II CS 351-50 Graphics API ( Application Programming Interface) Software library Layer between programmer and graphics hardware (and other software

More information

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1 Transformations 1-1 Transformations are used within the entire viewing pipeline: Projection from world to view coordinate system View modifications: Panning Zooming Rotation 1-2 Transformations can also

More information