Letterkenny Institute of Technology

Size: px
Start display at page:

Download "Letterkenny Institute of Technology"

Transcription

1 Letterkenny Institute of Technology BSc in Computing in Games Development Subject: Computer Graphics for Games Programming 2 Level: 7 Date: January 2008 Examiners: Dr. J.G. Campbell Dr. M.D.J. McNeill Time Allowed: Two hours INSTRUCTIONS Answer three questions from ve. C. Graphics for Games Prog. 2 Page 1 of 26 January 2008

2 1. Texture mapping. Figures 1 and 2 show parts of a program which draws a pyramid and applies a texture. The result is shown in Figure 3 and the original texture is shown in Figure 4. // white background glclearcolor(1.0f, 1.0f, 1.0f, 1.0f ); // Load texture glpixelstorei(gl_unpack_alignment, 1); pbytes = gltloadtga("tile.tga", &iwidth, &iheight, &icomponents, &eformat); glteximage2d(gl_texture_2d, 0, icomponents, iwidth, iheight, 0, eformat, GL_UNSIGNED_BYTE, pbytes); free(pbytes); gltexparameteri(gl_texture_2d, GL_TEXTURE_MIN_FILTER,GL_LINEAR);//A1 gltexparameteri(gl_texture_2d, GL_TEXTURE_MAG_FILTER,GL_LINEAR);//A2 gltexparameteri(gl_texture_2d, GL_TEXTURE_WRAP_S, GL_REPEAT); //B1 gltexparameteri(gl_texture_2d, GL_TEXTURE_WRAP_T, GL_REPEAT); //B2 gltexenvi(gl_texture_env, GL_TEXTURE_ENV_MODE, GL_MODULATE); glenable(gl_texture_2d); } //C Figure 1: Texture Code, Texture Setup C. Graphics for Games Prog. 2 Page 2 of 26 January 2008

3 void RenderScene(void){ M3DVector3f vnormal; M3DVector3f vcorners[5] = { { 0.0f,.80f, 0.0f }, // Top 0 { -0.5f, 0.0f, -.50f }, // Back left 1 { 0.5f, 0.0f, -0.50f }, // Back right 2 { 0.5f, 0.0f, 0.5f }, // Front right 3 { -0.5f, 0.0f, 0.5f }}; // Front left 4 glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); //... irrelevant code removed glcolor3f(1.0f, 1.0f, 1.0f); glbegin(gl_triangles); // Bottom section - two triangles glnormal3f(0.0f, -1.0f, 0.0f); gltexcoord2f(1.0f, 0.0f); glvertex3fv(vcorners[2]); gltexcoord2f(0.0f, 1.0f); glvertex3fv(vcorners[4]); gltexcoord2f(0.0f, 0.0f); glvertex3fv(vcorners[1]); gltexcoord2f(1.0f, 0.0f); glvertex3fv(vcorners[2]); gltexcoord2f(1.0f, 1.0f); glvertex3fv(vcorners[3]); gltexcoord2f(0.0f, 1.0f); glvertex3fv(vcorners[4]); // Front Face m3dfindnormal(vnormal, vcorners[0], vcorners[4], vcorners[3]); glnormal3fv(vnormal); gltexcoord2f(0.5f, 1.0f); glvertex3fv(vcorners[0]); gltexcoord2f(0.0f, 0.0f); glvertex3fv(vcorners[4]); gltexcoord2f(1.0f, 0.0f); glvertex3fv(vcorners[3]); // etc. for other faces... glend(); Figure 2: Texture Code, Rendering Pyramid C. Graphics for Games Prog. 2 Page 3 of 26 January 2008

4 Figure 3: Textured Pyramid. Figure 4: Texture. C. Graphics for Games Prog. 2 Page 4 of 26 January 2008

5 (a) Using diagrams as necessary, explain in detail how OpenGL texture mapping works and, in particular, the code for the texturing of the bottom section of the pyramid shown in the rst part of Figure 2. Since this question does not involve lighting, you should ignore any reference to normals. [8 marks] (b) (i) Explain the purpose of lines B1 and B2 in Figure 1; a diagram is strongly suggested. [4 marks] (ii) What would be the dierence (in general) if we changed the lines to those below? [2 marks] gltexparameteri(gl_texture_2d, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); //B1 gltexparameteri(gl_texture_2d, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); //B2 (c) (i) What is the pupose of the following line? (ii) What would be the dierence if we changed GL_MODULATE to GL_REPLACE? [4 marks] gltexenvi(gl_texture_env, GL_TEXTURE_ENV_MODE, GL_MODULATE); //C (d) (i) What are the lines below specifying? [2 marks] gltexparameteri(gl_texture_2d, GL_TEXTURE_MIN_FILTER,GL_LINEAR);//A1 gltexparameteri(gl_texture_2d, GL_TEXTURE_MAG_FILTER,GL_LINEAR);//A2 (ii) Figure 5 shows a situation in which texture interpolation is needed; we need a texture value for rendering point p; assuming monochrome (grey-level) for ease of working, the texel values are t1 = 10; t2 = 20; t3 = 30; t4 = 40; t5 = 50; t6 = 60; t7 = 70; t8 = 80; t9 = 90. Give an estimate for the grey-level at p, assuming the GL_LiNEAR specication in lines A1, A1; you will obtain full marks for showing good understanding of the principle involved. (iii) Repeat question (ii) for GL_NEAREST specication in lines A1, A1.. [3 marks] [2 marks] C. Graphics for Games Prog. 2 Page 5 of 26 January 2008

6 Figure 5: Texel interpolation. C. Graphics for Games Prog. 2 Page 6 of 26 January 2008

7 2. Lighting. Eqn. 1 summarises the version of the Phong lighting model used by OpenGL, N l I total = m e + sa i att i [l i m a a + l i m d d max(n L i ; 0) + l i m s smax((v R i ); 0) s ]: (1) i=1 N is the normal to the surface at the vertex in question; L i is the direction of light i; V is the viewing (eye) direction and R i is the specular reection direction for light i; sa is the spotlight attenuation factor and att distance attenuation; R is given by eqn. 2. (a) Explain how colour enters eqn. 1 R = 2(N L)N L: (2) (b) Based on eqn. 1, explain the following types of lighting, source, and material: (i) Ambient; (ii) Diuse; (iii) Specular ; (iv) Emissive. [4 marks] [10 marks] (There are 4 2 marks for (i) to (iv), plus 2 additional marks for a diagram showing the vectors mentioned in eqn. 1.) (c) Figure 6 shows some OpenGL code involving lighting and Figure 7 shows the resulting graphic. Explain lines //A, //B, and //C. Part 2(d) continued on page 10. [6 marks] C. Graphics for Games Prog. 2 Page 7 of 26 January 2008

8 void display(void){ glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glloadidentity (); gltranslated(-2.0, -3.0, -12.0); glenable(gl_lighting); glenable(gl_light0); glenable(gl_color_material); //A glcolormaterial(gl_front, GL_AMBIENT_AND_DIFFUSE); //B GLfloat l_amb[] = { 0.2, 0.2, 0.2, 1.0 }; GLfloat l_dif[] = { 0.2, 1.0, 0.2, 1.0 }; GLfloat l_spc[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat m_spc[] = { 1.0, 1.0, 1.0, 1.0 }; //GLfloat m_spc[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat m_shn[] = { 5.0 }; gllightmodelfv(gl_light_model_ambient, l_amb); //C GLfloat l_pos[] = { 20.0, 20.0, 20.0, 0.0 }; gllightfv (GL_LIGHT0, GL_POSITION, l_pos); gllightfv (GL_LIGHT0, GL_DIFFUSE, l_dif); gllightfv (GL_LIGHT0, GL_SPECULAR, l_spc); glmaterialfv(gl_front, GL_SPECULAR, m_spc); glmaterialfv(gl_front, GL_SHININESS, m_shn); house(); glpushmatrix(); gltranslated(4.0, 5.0, 0.0); glrotated(50.0, 1.0, 0.0, 0.0); glutsolidteapot(1.0); glpopmatrix(); glpushmatrix(); gltranslated(5.0, 0.0, 0.0); glrotated(30.0, 0.0, 1.0, 0.0); house(); glpopmatrix(); glpushmatrix(); gltranslated(0.0, 5.0, 0.0); glscaled(1.0, 1.0, 1.0); house(); glpopmatrix(); Figure 6: Lighted house code C. Graphics for Games Prog. 2 Page 8 of 26 January 2008

9 Figure 7: House gures. C. Graphics for Games Prog. 2 Page 9 of 26 January 2008

10 (d) Given the code fragment below, explain what will be the colour /shade at vertex vf[0]. Assume that material has zero specular reection; consider ambient and diuse only; assume that the light direction is in the direction of the normal; no attenuation. You should carefully explain your calculations. GLfloat l_amb[] = { 0.2, 0.3, 0.8, 1.0 }; GLfloat l_dif[] = { 0.4, 0.5, 0.9, 1.0 }; GLfloat l_spc[] = { 1.0, 1.0, 1.0, 1.0 }; //GLfloat m_spc[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat m_spc[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat m_shn[] = { 5.0 }; GLfloat m_amb[] = { 0.5, 0.5, 0.5, 1.0 }; GLfloat m_dif[] = { 0.8, 0.8, 0.8, 1.0 }; [5 marks] GLfloat l_pos[] = { 20.0, 20.0, 20.0, 0.0 }; gllightfv (GL_LIGHT0, GL_POSITION, l_pos); gllightfv (GL_LIGHT0, GL_DIFFUSE, l_dif); gllightfv (GL_LIGHT0, GL_AMBIENT, l_amb); gllightfv (GL_LIGHT0, GL_SPECULAR, l_spc); glmaterialfv(gl_front, GL_SPECULAR, m_spc); glmaterialfv(gl_front, GL_SHININESS, m_shn); glmaterialfv(gl_front, GL_AMBIENT, m_amb); glmaterialfv(gl_front, GL_DIFFUSE, m_dif); glvertex3fv(vf[0]); C. Graphics for Games Prog. 2 Page 10 of 26 January 2008

11 3. Display Lists and Vertex Arrays. Figure 8 shows some code that uses a display list and Figure 9 shows the resulting display. (a) Using Figure 8 as an example, give a detailed explanation of OpenGL display lists and how they can be used improve performance (frame rate, for example). In your answer, explain why the drawing of the four green larger triangles will require much more overall processing eort than the triangles in the display list. Hints: immediate mode, retained mode; what gets sent to the graphics card and when? [10 marks] (b) Change the code such that the display list contains the ve triangles, i.e. no need for the for (i = 0; i < 5; i++) loop. [5 marks] C. Graphics for Games Prog. 2 Page 11 of 26 January 2008

12 GLuint listname; static void triangle(float s){ glbegin (GL_TRIANGLES); glvertex2f (0.0, 0.0); glvertex2f (s, 0.0); glvertex2f (0.0, s); glend (); } static void init (void){ listname = glgenlists (1); glnewlist (listname, GL_COMPILE); glcolor3f (1.0, 0.0, 0.0); /* current color red */ triangle(1.0); gltranslatef (1.5, 0.0, 0.0); /* move position */ glendlist (); glshademodel (GL_FLAT); } static void drawline (void){ glbegin (GL_LINES); glvertex2f (0.0, 0.5); glvertex2f (15.0, 0.5); glend (); } void display(void){ GLuint i; } glclear (GL_COLOR_BUFFER_BIT); /* draw five red triangles */ for (i = 0; i < 5; i++){ glcalllist (listname); } glcolor3f (0.0, 1.0, 0.0); /* draw four green larger triangles */ for (i = 0; i < 4; i++){ triangle(1.2); gltranslatef (1.5, 0.0, 0.0); } glflush (); Figure 8: Display list example C. Graphics for Games Prog. 2 Page 12 of 26 January 2008

13 Figure 9: Output from display list example. C. Graphics for Games Prog. 2 Page 13 of 26 January 2008

14 (c) Vertex arrays. Examine the code in Figure 10. /* varray.cpp * varray.cpp, from varray.c j.g.c * This program demonstrates vertex arrays (OpenGL Red Book). * */ static GLint v[] = {25, 25, 100, 325, 175, 25, 175, 325, 250, 25, 325, 325}; static GLfloat c[] = {1.0, 0.2, 0.2, 0.2, 0.2, 1.0, 0.8, 1.0, 0.2, 0.75, 0.75, 0.75, 0.35, 0.35, 0.35, 0.5, 0.5, 0.5}; glenableclientstate (GL_VERTEX_ARRAY); // A glenableclientstate (GL_COLOR_ARRAY); // B glvertexpointer (2, GL_INT, 0, v); // C glcolorpointer (3, GL_FLOAT, 0, c); // D Figure 10: Vertex-arrays, varray.cpp (i) Explain the purpose of lines // A, // B, // C, and // D. [4 marks] (ii) Assuming the initialisation code in Figure 10 has been executed, the following line will produce the same display as the block of code marked // Two triangles. Why is the vertex array method more ecient? gldrawarrays (GL_TRIANGLES, 0, 6); glbegin(gl_triangles); // Two triangles glvertex2i(25, 25); glcolor3f(1.0, 0.2, 0.2); glvertex2i(100, 325); glcolor3f(0.2, 0.2, 1.0); glvertex2i(175, 25); glcolor3f(0.8, 1.0, 0.2); glvertex2i(175, 325); glcolor3f(0.75, 0.75, 0.75); glvertex2i(250, 25); glcolor3f(0.35, 0.35, 0.35); glvertex2i(325, 325); glcolor3f(0.5, 0.5, 0.5); glend(); (iii) How could interleaved arrays further increase eciency? [4 marks] [2 marks] C. Graphics for Games Prog. 2 Page 14 of 26 January 2008

15 4. Shaders and OpenGL Shading Language (GLSL). (a) Shaders or shader programs are a recent introduction to graphics and games programming. Give a brief explanation of shaders pitched at someone who has not heard of them, but who is familiar with OpenGL and its graphics pipeline. (b) Distinguish between vertex shader and fragment shader. [5 marks] [4 marks] (c) Using the example function setshader in Figure 11, explain the main steps in getting shader programs to execute; note, the question is worth only four marks, so keep your answer brief. (d) Examine the vertex shader in Figure 12 and answer the following questions. (i) What does line //A do? [4 marks] [2 marks] (ii) What does either line //B1 or //B2 (assuming the comment // was removed) do? [2 marks] (iii) Provide code, with explanation, that will squash x coordinates in the nal display by 0:5; clearly indicate where your code should be inserted in Figure 12. [2 marks] (iv) Provide code, with explanation, that will display negative colours in the nal display; alternatively, provide code, with explanation, that will display the nal display in grey-level; clearly indicate where your code should be inserted in Figure 12. (v) Vertex shaders are executed in a loop. Explain. (vi) Fragment shaders are executed in a loop. Explain. [2 marks] [2 marks] [2 marks] C. Graphics for Games Prog. 2 Page 15 of 26 January 2008

16 void setshaders() { char *vs = NULL, *fs = NULL; v = glcreateshader(gl_vertex_shader); f = glcreateshader(gl_fragment_shader); //f2 = glcreateshader(gl_fragment_shader); vs = textfileread("color.vert"); fs = textfileread("color.frag"); const char *vv = vs; const char *ff = fs; printf("\nvertex shader... \n %s \n", vv); printf("fragment shader... \n %s \n", ff); glshadersource(v, 1, &vv, NULL); glshadersource(f, 1, &ff, NULL); free(vs); free(fs); glcompileshader(v); glcompileshader(f); //glcompileshader(f2); p = glcreateprogram(); glattachshader(p, f); //glattachshader(p, f2); glattachshader(p, v); gllinkprogram(p); gluseprogram(p); //gluseprogram(0); // revert to fixed-function } loc = glgetuniformlocation(p, "time"); Figure 11: Shader Set Up C. Graphics for Games Prog. 2 Page 16 of 26 January 2008

17 // diffuse.vs // // Generic vertex transformation, // diffuse lighting based on one white light uniform vec3 lightpos[1]; void main(void){ gl_position = gl_modelviewprojectionmatrix * gl_vertex; //A vec3 N = normalize(gl_normalmatrix * gl_normal); vec4 V = gl_modelviewmatrix * gl_vertex; vec3 L = normalize(lightpos[0] - V.xyz); } float NdotL = dot(n, L); gl_frontcolor = gl_color * vec4(max(0.0, NdotL)); //B1 //gl_frontcolor = vec4(1.0, 1.0, 0.0, 0.0); //B2 Figure 12: Vertex Shader Implementing Diuse Lighting. C. Graphics for Games Prog. 2 Page 17 of 26 January 2008

18 5. Miscellaneous Questions on projective transformations, GLU quadrics. (a) Compare and contrast orthographic projection with perspective projection. Use of diagram(s) is strongly encouraged. [5 marks] (b) Referring as necessary to eqn. 13 on page 23, compute the the values that will be in projection matrix after the call to glortho at //A. void glortho(gldouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far); left = -50.0; right = 25.0; bottom = 0.0; top = 50.0; near = -1.0; far = 5.0; glmatrixmode(gl_projection); glloadidentity(); glortho(left, right, bottom, top, near, far); //A [5 marks] (c) Quadric surfaces, such as those provided by GLU Quadrics are dened by the general quadratic equation, q(x; y ; z) = ax 2 + by 2 + cz 2 + 2dxy + 2ey z + 2f xz + 2gx + 2hy + 2jz + k = 0: (3) (i) What are the values of a; b; c; : : : for the plane through x = 1 parallel to the y- and z- axes, given by eqn. 4? [1 marks] x 1 = 0 (4) (ii) Show that eqn. 3 and the matrix form in eqn. 5 are equivalent. Hint: multiply out eqn. 5 and remember that w = 1. where u = x y z w = 1, and Q = u T Q u = 0; (5) a d f g d b e h : f e c j g h j k (d) The surface normal to the quadric given by eqn. 3 is given by Use this to derive the normal to the plane [4 marks] n @y ): x 1 = 0 (7) [5 marks] C. Graphics for Games Prog. 2 Page 18 of 26 January 2008

19 (e) Explain the purpose of each line, //1, //2, //3, in the following code fragment. GLUquadricObj *s; s = glunewquadric(); //1 gluquadricdrawstyle(s, GLU_LINE); //2 int nlong = 10, nlat = 8; float r = 1.0; glusphere(s, r, nlong, nlat); //3 [3 marks] Give a rough drawing of what the code fragment will draw. [2 marks] C. Graphics for Games Prog. 2 Page 19 of 26 January 2008

20 Appendix A. 3D Ane Transformations using Homogeneous Coordinates. Translation v x v y v z v w = t x t y t z u x u y u z u w : (8) Rotation about the z-axis Rotation about the x-axis R z (b) = R x (b) = cos b sin b 0 0 sin b cos b cos b sin b 0 0 sin b cos b : (9) : (10) Rotation about the y-axis R y (b) = cos b 0 sin b sin b 0 cos b : (11) C. Graphics for Games Prog. 2 Page 20 of 26 January 2008

21 Appendix B. 3D Projection Transformations using Homogeneous Coordinates. Perspective Transformation x 0 p z y 0 p z z 0 p z w 0 = 2n 0 r l r +l 0 r l t+b 0 t b 2n 0 t b f +n 0 0 f n nf f n p x p y p z 1 : (12) void glfrustum(gldouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far). Figure 13 shows what the arguments mean. Figure 13: Perspective view frustum volume dened by glfrustum. gluperspective is more intuitive to use: gluperspective(float fovangley, float aspectratio, float near, float far); // these two are equivalent tanby2 = tan(fovy/2.0); gluperspective(fovy, aspectratio, n, 20.0); // glfrustum (-n*tanby2, n*tanby2, -n*tanby2*aspectratio, n*tanby2*aspectratio, n, 20.0); Figure 14 shows what the arguments mean. Compare with the equivalent glfrustum diagram, Figure 13. C. Graphics for Games Prog. 2 Page 21 of 26 January 2008

22 Figure 14: gluperspective. C. Graphics for Games Prog. 2 Page 22 of 26 January 2008

23 Orthographic Transformation r l t b f n r +l r l t+b t b f +n f n : (13) void glortho(gldouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far). C. Graphics for Games Prog. 2 Page 23 of 26 January 2008

24 Appendix C. Cubic Bezier curves. Bernstein polynomials can be dened as follows: ( ) n B n (u) = i u i (1 u) n i ; (14) i where the value of the binomial coecient ( ) n i is given by ( ) n n! = n C i = i i!(n i)!) : (15) Cubic Bezier curves are based on the four Bernstein polynomial blending functions, B 3 0 ; B3 1 ; B3, 1 and B 3 3 shown in Figure 15. B 3 (u) 0 = u3 ; (16) B 3 (u) 1 = 3u2 (1 u); B 3 (u) 2 = 3u(1 u)2 ; B 3 (u) 3 = (1 u)3 : Figure 15: Blending functions. Linear (left) and cubic Bernstein (Bezier) (right). C. Graphics for Games Prog. 2 Page 24 of 26 January 2008

25 Appendix D. OpenGL Graphics Primitives. Figure 16 shows the list of possible graphics primitives and possible arguments for glbegin and Figure 17 gives a diagrammatic explanation. GL_POINTS individual points GL_LINES pairs of vertices interpreted as individual line segments GL_POLYGON boundary of a simple, convex polygon GL_TRIANGLES triples of vertices interpreted as triangles GL_QUADS quadruples of vertices interpreted as four-sided polygons GL_LINE_STRIP series of connected line segments GL_LINE_LOOP same as above, with a segment added between last and first vertices GL_TRIANGLE_STRIP linked strip of triangles GL_TRIANGLE_FAN linked fan of triangles GL_QUAD_STRIP linked strip of quadrilaterals Figure 16: Geometric Primitive Names and Meanings. C. Graphics for Games Prog. 2 Page 25 of 26 January 2008

26 Figure 17: Geometric Primitive Types. C. Graphics for Games Prog. 2 Page 26 of 26 January 2008

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

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

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

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

Programming with OpenGL Part 2: Complete Programs Computer Graphics I, Fall

Programming with OpenGL Part 2: Complete Programs Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs 91.427 Computer Graphics I, Fall 2008 1 1 Objectives Refine first program Alter default values Introduce standard program structure Simple viewing 2-D

More information

A display list is a group of OpenGL commands that have been stored for later execution.

A display list is a group of OpenGL commands that have been stored for later execution. Introduction A display list is a group of OpenGL commands that have been stored for later execution. Most OpenGL commands can be either stored in a display list or issued in immediate mode. 1 For example,

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. 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

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

Programmable shader. Hanyang University

Programmable shader. Hanyang University Programmable shader Hanyang University Objective API references (will be skipped) Examples Simple shader Phong shading shader INTRODUCTION GLSL(OPENGL SHADING LANGUAGE) Scalar Data types Structure Structures

More information

Display Lists in OpenGL

Display Lists in OpenGL Display Lists in OpenGL Display lists are a mechanism for improving performance of interactive OpenGL applications. A display list is a group of OpenGL commands that have been stored for later execution.

More information

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 2: First Program

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 2: First Program Comp 410/510 Computer Graphics Spring 2017 Programming with OpenGL Part 2: First Program Objectives Refine the first program Introduce a standard program structure - Initialization Program Structure Most

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

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

Computer graphics MN1

Computer graphics MN1 Computer graphics MN1 http://www.opengl.org Todays lecture What is OpenGL? HowdoI useit? Rendering pipeline Points, vertices, lines, polygons Matrices and transformations Lighting and shading Code examples

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

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

Programming of Graphics

Programming of Graphics Peter Mileff PhD Programming of Graphics Introduction to OpenGL University of Miskolc Department of Information Technology OpenGL libraries GL (Graphics Library): Library of 2D, 3D drawing primitives and

More information

Lectures Display List

Lectures Display List Lectures Display List 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 it? What

More information

CSE 4431/ M Advanced Topics in 3D Computer Graphics. TA: Margarita Vinnikov

CSE 4431/ M Advanced Topics in 3D Computer Graphics. TA: Margarita Vinnikov CSE 4431/5331.03M Advanced Topics in 3D Computer Graphics TA: Margarita Vinnikov mvinni@cse.yorku.ca What do we need to do to use shaders in our program? Shaders Work flow For multiple shaders 1. Create

More information

GL_MODELVIEW transformation

GL_MODELVIEW transformation lecture 3 view transformations model transformations GL_MODELVIEW transformation view transformations: How do we map from world coordinates to camera/view/eye coordinates? model transformations: How do

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

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

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

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

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

1)Write a shader program that renders a regular pentagon with textured image like the one shown below.

1)Write a shader program that renders a regular pentagon with textured image like the one shown below. Andrew Yenalavitch CSE520 Winter 2015 Quiz 2 Report 1)Write a shader program that renders a regular pentagon with textured image like the one shown below. Use the following provided image for the texture:

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

IntMu.Lab5. Download all the files available from

IntMu.Lab5. Download all the files available from IntMu.Lab5 0. Download all the files available from http://www.dee.isep.ipp.pt/~jml/intmu/lab5: wget http://www.dee.isep.ipp.pt/~jml/intmu/lab5/makefile make getall Analyze the program windmill.c. Compile

More information

OpenGL An introduction

OpenGL An introduction OpenGL An introduction Camilla Berglund elmindreda@stacken.kth.se Introductory illustration by theodore This material is under a Creative Commons license http://creativecommons.org/licenses/by-sa/2.5/se/

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

Geometry Primitives. Computer Science Department University of Malta. Sandro Spina Computer Graphics and Simulation Group. CGSG Geometry Primitives

Geometry Primitives. Computer Science Department University of Malta. Sandro Spina Computer Graphics and Simulation Group. CGSG Geometry Primitives Geometry Primitives Sandro Spina Computer Graphics and Simulation Group Computer Science Department University of Malta 1 The Building Blocks of Geometry The objects in our virtual worlds are composed

More information

Display Lists. Conceptually similar to a graphics file. In client-server environment, display list is placed on server

Display Lists. Conceptually similar to a graphics file. In client-server environment, display list is placed on server Display Lists Conceptually similar to a graphics file Must define (name, create) Add contents Close In client-server environment, display list is placed on server Can be redisplayed without sending primitives

More information

Introduction to OpenGL

Introduction to OpenGL Introduction to OpenGL 1995-2015 Josef Pelikán & Alexander Wilkie CGG MFF UK Praha pepca@cgg.mff.cuni.cz http://cgg.mff.cuni.cz/~pepca/ 1 / 31 Advances in Hardware 3D acceleration is a common feature in

More information

Computer Graphics. Transformations. CSC 470 Computer Graphics 1

Computer Graphics. Transformations. CSC 470 Computer Graphics 1 Computer Graphics Transformations CSC 47 Computer Graphics 1 Today s Lecture Transformations How to: Rotate Scale and Translate 2 Introduction An important concept in computer graphics is Affine Transformations.

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

Luiz Fernando Martha André Pereira

Luiz Fernando Martha André Pereira Computer Graphics for Engineering Numerical simulation in technical sciences Color / OpenGL Luiz Fernando Martha André Pereira Graz, Austria June 2014 To Remember Computer Graphics Data Processing Data

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

5.2 Shading in OpenGL

5.2 Shading in OpenGL Fall 2017 CSCI 420: Computer Graphics 5.2 Shading in OpenGL Hao Li http://cs420.hao-li.com 1 Outline Normal Vectors in OpenGL Polygonal Shading Light Sources in OpenGL Material Properties in OpenGL Example:

More information

Shading in OpenGL. Outline. Defining and Maintaining Normals. Normalization. Enabling Lighting and Lights. Outline

Shading in OpenGL. Outline. Defining and Maintaining Normals. Normalization. Enabling Lighting and Lights. Outline CSCI 420 Computer Graphics Lecture 10 Shading in OpenGL Normal Vectors in OpenGL Polygonal Shading Light Source in OpenGL Material Properties in OpenGL Approximating a Sphere [Angel Ch. 6.5-6.9] Jernej

More information

Overview. Shading. Shading. Why we need shading. Shading Light-material interactions Phong model Shading polygons Shading in OpenGL

Overview. Shading. Shading. Why we need shading. Shading Light-material interactions Phong model Shading polygons Shading in OpenGL Overview Shading Shading Light-material interactions Phong model Shading polygons Shading in OpenGL Why we need shading Suppose we build a model of a sphere using many polygons and color it with glcolor.

More information

Assignment 1. Simple Graphics program using OpenGL

Assignment 1. Simple Graphics program using OpenGL Assignment 1 Simple Graphics program using OpenGL In this assignment we will use basic OpenGL functions to draw some basic graphical figures. Example: Consider following program to draw a point on screen.

More information

OpenGL. White Square Code 11/4/09. OpenGL. OpenGL. OpenGL

OpenGL. White Square Code 11/4/09. OpenGL. OpenGL. OpenGL OpenGL OpenGL OpenGL Is a mechanism to create images in a frame buffer Is an API to access that mechanism Is well specified OpenGL Is not a window system Is not a user interface Is not a display mechanism

More information

Computer Graphics. Making Pictures. Computer Graphics CSC470 1

Computer Graphics. Making Pictures. Computer Graphics CSC470 1 Computer Graphics Making Pictures Computer Graphics CSC470 1 Getting Started Making Pictures Graphics display: Entire screen (a); windows system (b); [both have usual screen coordinates, with y-axis y

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

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

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

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

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

CS 148, Summer 2012 Introduction to Computer Graphics and Imaging

CS 148, Summer 2012 Introduction to Computer Graphics and Imaging http://www.ann.jussieu.fr/~frey/papers/scivi/cook%20r.l.,%20a%20reflectance%20model%20for%20computer%20graphics.pdf CS 148, Summer 2012 Introduction to Computer Graphics and Imaging f(~v 2 ) A 3 A 1 f(~v

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

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

Modeling with Transformations

Modeling with Transformations Modeling with Transformations Prerequisites This module requires some understanding of 3D geometry, particularly a sense of how objects can be moved around in 3-space. The student should also have some

More information

Teacher Assistant : Tamir Grossinger Reception hours: by - Building 37 / office -102 Assignments: 4 programing using

Teacher Assistant : Tamir Grossinger   Reception hours: by  - Building 37 / office -102 Assignments: 4 programing using Teacher Assistant : Tamir Grossinger email: tamirgr@gmail.com Reception hours: by email - Building 37 / office -102 Assignments: 4 programing using C++ 1 theoretical You can find everything you need in

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

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

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

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

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

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

Computer graphics Labs: OpenGL (1/3) Geometric transformations and projections

Computer graphics Labs: OpenGL (1/3) Geometric transformations and projections University of Liège Department of Aerospace and Mechanical engineering Computer graphics Labs: OpenGL (1/3) Geometric transformations and projections Exercise 1: Geometric transformations (Folder transf

More information

SE313: Computer Graphics and Visual Programming. Computer Graphics Notes Gazihan Alankus, Fall 2011

SE313: Computer Graphics and Visual Programming. Computer Graphics Notes Gazihan Alankus, Fall 2011 SE313: Computer Graphics and Visual Programming Computer Graphics Notes Gazihan Alankus, Fall 2011 Computer Graphics Geometrical model on the computer -> Image on the screen How it works in your computer

More information

compatibility mode core mode

compatibility mode core mode Using the GLUT This document provides a more detailed description of the minimum steps necessary to write build and execute an OpenGL 3D application that runs on the three desktop platforms Windows, OSX

More information

INF3320 Computer Graphics and Discrete Geometry

INF3320 Computer Graphics and Discrete Geometry INF3320 Computer Graphics and Discrete Geometry Visual appearance Christopher Dyken and Martin Reimers 23.09.2009 Page 1 Visual appearance Real Time Rendering: Chapter 5 Light Sources and materials Shading

More information

Today s class. Simple shadows Shading Lighting in OpenGL. Informationsteknologi. Wednesday, November 21, 2007 Computer Graphics - Class 10 1

Today s class. Simple shadows Shading Lighting in OpenGL. Informationsteknologi. Wednesday, November 21, 2007 Computer Graphics - Class 10 1 Today s class Simple shadows Shading Lighting in OpenGL Wednesday, November 21, 27 Computer Graphics - Class 1 1 Simple shadows Simple shadows can be gotten by using projection matrices Consider a light

More information

Supplement to Lecture 22

Supplement to Lecture 22 Supplement to Lecture 22 Programmable GPUs Programmable Pipelines Introduce programmable pipelines - Vertex shaders - Fragment shaders Introduce shading languages - Needed to describe shaders - RenderMan

More information

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

Three-Dimensional Graphics V. Guoying Zhao 1 / 55 Computer Graphics Three-Dimensional Graphics V Guoying Zhao 1 / 55 Shading Guoying Zhao 2 / 55 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material

More information

2D Drawing Primitives

2D Drawing Primitives THE SIERPINSKI GASKET We use as a sample problem the drawing of the Sierpinski gasket an interesting shape that has a long history and is of interest in areas such as fractal geometry. The Sierpinski gasket

More information

1) Here is the various stages of the tetrahedron:

1) Here is the various stages of the tetrahedron: Andrew Yenalavitch Homework 3 CSE 520 - Winter 2015 1) ( 20 points ) Write a shader program that renders a colored tetrahedron, which gradually shrinks to a point and expands back to its original shape.

More information

Lecture 5b. Transformation

Lecture 5b. Transformation Lecture 5b Transformation Refresher Transformation matrices [4 x 4]: the fourth coordinate is homogenous coordinate. Rotation Transformation: Axis of rotation must through origin (0,0,0). If not, translation

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

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010) Lecture 5: Viewing CSE 40166 Computer Graphics (Fall 2010) Review: from 3D world to 2D pixels 1. Transformations are represented by matrix multiplication. o Modeling o Viewing o Projection 2. Clipping

More information

CSC 8470 Computer Graphics. What is Computer Graphics?

CSC 8470 Computer Graphics. What is Computer Graphics? CSC 8470 Computer Graphics What is Computer Graphics? For us, it is primarily the study of how pictures can be generated using a computer. But it also includes: software tools used to make pictures hardware

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

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

Rendering Pipeline/ OpenGL

Rendering Pipeline/ OpenGL Chapter 2 Basics of Computer Graphics: Your tasks for the weekend Piazza Discussion Group: Register Post review questions by Mon noon Use private option, rev1 tag Start Assignment 1 Test programming environment

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

Programming with OpenGL Part 1: Background

Programming with OpenGL Part 1: Background Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico 1 Objectives Development of the OpenGL API

More information

Lecture 22 Sections 8.8, 8.9, Wed, Oct 28, 2009

Lecture 22 Sections 8.8, 8.9, Wed, Oct 28, 2009 s The s Lecture 22 Sections 8.8, 8.9, 8.10 Hampden-Sydney College Wed, Oct 28, 2009 Outline s The 1 2 3 4 5 The 6 7 8 Outline s The 1 2 3 4 5 The 6 7 8 Creating Images s The To create a texture image internally,

More information

Information Coding / Computer Graphics, ISY, LiTH GLSL. OpenGL Shading Language. Language with syntax similar to C

Information Coding / Computer Graphics, ISY, LiTH GLSL. OpenGL Shading Language. Language with syntax similar to C GLSL OpenGL Shading Language Language with syntax similar to C Syntax somewhere between C och C++ No classes. Straight ans simple code. Remarkably understandable and obvious! Avoids most of the bad things

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

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

GEOMETRIC OBJECTS AND TRANSFORMATIONS I

GEOMETRIC OBJECTS AND TRANSFORMATIONS I Computer UNIT Graphics - 4 and Visualization 6 Hrs GEOMETRIC OBJECTS AND TRANSFORMATIONS I Scalars Points, and vectors Three-dimensional primitives Coordinate systems and frames Modelling a colored cube

More information

Information Coding / Computer Graphics, ISY, LiTH. OpenGL! ! where it fits!! what it contains!! how you work with it 11(40)

Information Coding / Computer Graphics, ISY, LiTH. OpenGL! ! where it fits!! what it contains!! how you work with it 11(40) 11(40) Information Coding / Computer Graphics, ISY, LiTH OpenGL where it fits what it contains how you work with it 11(40) OpenGL The cross-platform graphics library Open = Open specification Runs everywhere

More information

Building Models. Prof. George Wolberg Dept. of Computer Science City College of New York

Building Models. Prof. George Wolberg Dept. of Computer Science City College of New York Building Models Prof. George Wolberg Dept. of Computer Science City College of New York Objectives Introduce simple data structures for building polygonal models - Vertex lists - Edge lists Deprecated

More information

How OpenGL Works. Retained Mode. Immediate Mode. Introduction To OpenGL

How OpenGL Works. Retained Mode. Immediate Mode. Introduction To OpenGL How OpenGL Works Introduction To OpenGL OpenGL uses a series of matrices to control the position and way primitives are drawn OpenGL 1.x - 2.x allows these primitives to be drawn in two ways immediate

More information

Methodology for Lecture. Importance of Lighting. Outline. Shading Models. Brief primer on Color. Foundations of Computer Graphics (Spring 2010)

Methodology for Lecture. Importance of Lighting. Outline. Shading Models. Brief primer on Color. Foundations of Computer Graphics (Spring 2010) Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 11: OpenGL 3 http://inst.eecs.berkeley.edu/~cs184 Methodology for Lecture Lecture deals with lighting (teapot shaded as in HW1) Some Nate

More information

Computer Graphics Primitive Attributes

Computer Graphics Primitive Attributes Computer Graphics 2015 4. Primitive Attributes Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2015-10-12 Previous lessons - Rasterization - line - circle /ellipse? => homework - OpenGL and

More information

8 Three-Dimensional Object Representations. Chapter 8. Three-Dimensional Object Representations. Department of Computer Science and Engineering 8-1

8 Three-Dimensional Object Representations. Chapter 8. Three-Dimensional Object Representations. Department of Computer Science and Engineering 8-1 Chapter 8 Three-Dimensional Object Representations 8-1 8.1 Overview The main goal of three-dimensional computer graphics is to generate two-dimensional images of a scene or of an object based on a a description

More information

Announcement. Homework 1 has been posted in dropbox and course website. Due: 1:15 pm, Monday, September 12

Announcement. Homework 1 has been posted in dropbox and course website. Due: 1:15 pm, Monday, September 12 Announcement Homework 1 has been posted in dropbox and course website Due: 1:15 pm, Monday, September 12 Today s Agenda Primitives Programming with OpenGL OpenGL Primitives Polylines GL_POINTS GL_LINES

More information

Shading and Illumination

Shading and Illumination Shading and Illumination OpenGL Shading Without Shading With Shading Physics Bidirectional Reflectance Distribution Function (BRDF) f r (ω i,ω ) = dl(ω ) L(ω i )cosθ i dω i = dl(ω ) L(ω i )( ω i n)dω

More information

Why we need shading?

Why we need shading? Why we need shading? Suppose we build a model of a sphere using many polygons and color it with glcolor. We get something like But we want Light-material interactions cause each point to have a different

More information

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department CSE 690: GPGPU Lecture 2: Understanding the Fabric - Intro to Graphics Klaus Mueller Stony Brook University Computer Science Department Klaus Mueller, Stony Brook 2005 1 Surface Graphics Objects are explicitely

More information

Computer graphic -- Programming with OpenGL I

Computer graphic -- Programming with OpenGL I Computer graphic -- Programming with OpenGL I A simple example using OpenGL Download the example code "basic shapes", and compile and run it Take a look at it, and hit ESC when you're done. It shows the

More information

CS 543 Lecture 1 (Part 3) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

CS 543 Lecture 1 (Part 3) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI) Computer Graphics CS 543 Lecture 1 (Part 3) Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Recall: OpenGL Skeleton void main(int argc, char** argv){ // First initialize

More information

Chapter 7 Display Lists

Chapter 7 Display Lists OpenGL Programming Guide (Addison-Wesley Publishing Company) Chapter 7 Display Lists Chapter Objectives After reading this chapter, you ll be able to do the following: Understand how display lists can

More information

Cheating: In case of cheating, all parts involved (source(s) and receiver(s)) get zero.

Cheating: In case of cheating, all parts involved (source(s) and receiver(s)) get zero. REGULATIONS Due date: 19.11.2009 Thursday 23:59 Late Submission: Late submission is not allowed. Submission: Use the COW system to submit your homework file. The homework should be done and submitted individually.

More information