三維繪圖程式設計 3D Graphics Programming Design 第三章三維繪圖狀態設定和幾何元件繪製嘉大資工系盧天麒

Size: px
Start display at page:

Download "三維繪圖程式設計 3D Graphics Programming Design 第三章三維繪圖狀態設定和幾何元件繪製嘉大資工系盧天麒"

Transcription

1 三維繪圖程式設計 3D Graphics Programming Design 第三章三維繪圖狀態設定和幾何元件繪製嘉大資工系盧天麒 1

2 In this chapter, you will learn How to access values in the OpenGL state machine The types of primitives available in OpenGL How to modify the way primitives are handle and displayed 2

3 State functions OpenGL provides a number of multipurpose functions that allow to query the OpenGL state machine Most of which begin with glget 3

4 Querying numeric states 4 functions to retrieve values glgetbooleanv(glenum pname, GLboolean *params) glgetdoublev(glenum pname, GLdouble *params) glgetfloatv(glenum pname, GLfloat *params) glgetintegerv(glenum pname, GLint *params) The parameter pname The state setting you are query params An array to hold all values associated with the setting 4

5 Enabling and disabling states Turn the states on and off glenable(glenum cap) gldisable(glnum cap ) Over 40 capabilities to enable and disable GL_BLEND, GL_TEXTURE_2D, GL_LIGHTING 5

6 glisenabled( ) Find out whether a particular OpenGL capability is on or off It is usually easier to use GLboolean glisenabled(glenum cap); The function can be called with any of the values accepted by glenable( ) / gldisable( ) GL_TRUE and GL_FALSE 6

7 Querying String Values You can find out the details of the OpenGL implementation being used at runtime const GLubyte *glgetstring(glenum name); 7

8 Finding Errors Passing incorrect values to OpenGL functions Cause an error flag to be set Querying the error flag can help you to more easily track down problems in your code You can do this through GLenum glgeterror( ); 8

9 Finding Errors The returns one of the values in the following 9

10 Giving OpenGL a Hint Allow developers a level of control over the trade-off between image quality and speed The glhint( ) function allows you to specify your desired level of trade-off void glhint(glenum target, GLenum hint); 10

11 Giving OpenGL a Hint The target parameter specifies the behavior you want to control 11

12 Giving OpenGL a Hint The hint parameter can be one of the three options GL_FASTEST sacrificing quality GL_NICEST losing performance GL_DONT_CARE OpenGL driver will decide what it thinks is best 12

13 Handling Primitives Basic geometric entities Points, lines, and triangles The first is void glbegin(glenum mode); void glend(); You use glbegin( ) to tell OpenGL two things Ready to start drawing The primitive type you want to draw 13

14 14

15 Handling Primitives glbegin( ) / glend( ) blocks may not be nested Not all OpenGL functions cab be used inside a glbegin( ) / glend( ) block Only variations of the function listed in the following table may be used 15

16 16

17 Handling Primitives Draw with OpenGL void glvertex{234}{dfis}( ); void glvertex{234}{dfis}v( ); For example glvertex2i(5, 20); glvertex3f(1.5, 0.5, 10.0); GLfloat v[3]={1.5, 0.5, 10.0}; glvertex3fv(v); 17

18 Drawing Points in 3D Draw a point in OpenGL glbegin(gl_points); glvertex3f(0.0, 0.0, 0.0); glend(); Draw two points glbegin(gl_points); glvertex3f(0.0, 0.0, 0.0); glvertex3f(0.0, 1.0, 0.0); glend(); 18

19 Modifying Point Size To change the point size void glpointsize(glfloat size); The default size is 1.0 Find out the current selected size GLfloat oldsize; glgetfloatv(gl_point_size, &oldsize); 19

20 Antialiasing Points There is finite number of pixels on the screen Cause the edges of primitives to look jagged Antialiasing provides a means of smoothing out the edges Give edges a more realistic look 20

21 Antialiasing Points If you want to use antialiasing, you can Turn it on by passing GL_POINT_SMOOTH to glenable( ) Turn it off again by passing the same parameter to gldisable( ) 21

22 Antialiasing Points If you are unsure whether point antialiasing is enabled or disabled, you find out by calling glget( ) with GL_POINT_SMOOTH, or with glisenabled(gl_point_smooth) Here is an example If (!glisenable(gl_point_smooth)) glenable(gl_point_smooth); 22

23 Effect of Distance Points always occupy the same amount of space on the screen For some applications of points, you will want the points to be smaller as they get farther away Such as particle systems 23

24 Effect of Distance You can do this through the use of the glpointparameter( ) function void glpointparameter{if}(enum pname, type param); void glpointparameter{if}v(enum pname, const type *params); 24

25 A Pointy Example Each point s size increases in the row Each point separated by 0.5 units float pointsize = 0.5; // draw a line of points of increasing size for (float point = -4.0; point < 5.0; point+=0.5) { glpointsize(pointsize); // set the point size // draw the point glbegin(gl_point); glvertex3f(point, 0.0, 0.0); glend(); // increase the point size for the next point pointsize += 1.0; } 25

26 26

27 Drawing Lines in 3D Passing GL_LINES to glbegin( ) glbegin(gl_lines); glvertex3f(-2.0, -1.0, 0.0); glvertex3f(3.0, 1.0, 0.0); glend(); 27

28 Modifying Line Width The default line width is 1.0 void gllinewidth(glfloat width); GLfloat oldwidth; glgetfloatv(gl_line_width, &oldwidth); If (oldwidth < 1.0) gllinewidth(5.0); 28

29 Antialiasing Lines Antialiasing for lines works very much as it does with points You can turn it on and off by passing GL_LINE_SMOOTH to glenable( ) and gldisable( ) The current state can be determined by passing GL_LINE_SMOOTH to glget( ) or glisenabled( ) It is disabled by default 29

30 Antialiasing Lines Here is an example of how to do that GLfloat sizes[2]; GLfloat granularity; glgetfloatv(gl_line_width_range, sizes); GLfloat minlinewidth = sizes[0]; GLfloat maxlinewidth = sizes[1]; glgetfloatv(gl_line_width_granularity, &granularity); 30

31 Drawing Polygons in 3D To change the way polygons are drawn void glpolygonmode(glenum face, GLenum mode); Polygons modes GL_POINT, GL_LINE, GL_FILL OpenGL handles the front and back faces of polygons separately Polygons are drawn filled by default glpolygonmode(gl_front, GL_FILL); glpolygonmode(gl_back, GL_LINE); 31

32 Polygon Mode Example Five squares rotating clockwise at the same rate Starting from the left glpolygonmode(gl_front, GL_LINE); glpolygonmode(gl_back, GL_POINT); glpolygonmode(gl_front_and_back, GL_FILL); glpolygonmode(gl_back, GL_LINE); glpolygonmode(gl_front_and_back, GL_LINE); 32

33 Polygon Face Culling It is possible to have OpenGL to eliminate polygons that the viewer can not see Culling OpenGL can do this for you automatically 33

34 Polygon Face Culling First, passing GL_CULL_FACE to glenable( ) Then you need to specify which face you want culled Call glcullface( ) void glcullface(glenum mode); Mode can be GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK GL_BACK is the default setting 34

35 Polygon Face Culling The next step is telling OpenGL how to determine whether a polygon is front or back facing Polygon winding You have to proceed either clockwise or counterclockwise around its vertices 35

36 Polygon Face Culling By default Counterclockwise (CCW) ordering as frontfacing Clockwise (CW) ordering as back-facing The default behavior can be changed using glfrontface( ) void glfrontface(glenum mode); Mode should GL_CCW or GL_CW 36

37 Hiding Polygon Edges Wire-frame or all the edges of your polygons show up For example, you may not want the viewer to see the diagonal line void gledgeflag(glboolean isedge); The flag is set to GL_TRUE (the default) Drawn The flag is set to GL_FLASE Not to draw 37

38 38

39 Antialiasing Polygons As with points and lines, you can also choose to antialias polygons By passing GL_POLYGON_SMOOTH to glenable( ) and gldisable( ) The current state can be determined By passing the same parameter to glget( ) or glisenable( ) It is disabled by default 39

40 Antialiasing Polygons Here is an example of how to enable polygon antialiasing if (!glisenabled(gl_polygon_smooth)) glenable(gl_polygon_smooth); 40

41 Triangles Triangles are the preferred polygon form Three points define a plane A triangle is always convex A triangle can not cross over itself glbegin(gl_triangles); glvertex3f(-2.0, -1.0, 0.0); glvertex3f(3.0, 1.0, 0.0); glvertex3f(0.0, 3.0, 0.0); glend(); The number of vertices defined isn t a multiple of 3, then the extra vertices are discarded 41

42 42

43 Triangles Triangle strips Call glbegin( ) with GL_TRIANGLE_STRIP Draw the first three vertices Take every specified and combine it with the previous two vertices Reduce the number of vertices from 3n to n+2 43

44 Triangles Triangle fans Call glbegin( ) with GL_TRIANGLE_FAN A series of triangles around a single central vertex The first vertex specified is the central vertex Every following adjacent pair of vertices is combined with the center vertex Draw n triangles while specifying only n+2 vertices 44

45 45

46 Quadrilaterals Four-sided polygons To draw a square or rectangle Call glbegin( ) with GL_GUADS and specifying four or more vertices 46

47 Quadrilaterals OpenGL provides quad strips as a means of improving the speed of rendering quads They are specified using GL_QUAD_STRIP Each pair of vertices specified after the first pair defines a new quad 47

48 Polygons An arbitrary number of vertices If fewer than three vertices, nothing is drawn 48

49 Using Primitives: Triangles and Quads Example The final example for this chapter TrianglesQuads A set of six grids with a different primitive type 49

50

51 Using primitives: triangles and quads example DrawPoints Void DrawPoints() { glpointsize(4.0); glbegin(gl_points); for (int x = 0; x < 4; x++) for (int z = 0; z < 4; z++) glvertex3f(x, 0, z); glend(); }

52 Using primitives: triangles and quads example DrawTriangles Void DrawTriangles() { glbegin(gl_triangles); for (int x = 0; x < 3; x++) for (int z = 0; z < 3; z++) glvertex3f(x, 0.0, z); glvertex3f((x+1.0), 0, z); glvertex3f(x, 0.0, (z+1.0)); glend(); }

53 Using primitives: triangles and quads example DrawQuads Void DrawQuads() { glbegin(gl_quads); for (int x = 0; x < 3; x++) for (int z = 0; z < 3; z++) glvertex3f(x, 0.0, z); glvertex3f((x+1).0, 0, z); glvertex3f((x+1).0, 0, (z+1)); glvertex3f(x, 0.0, (z+1.0)); glend(); }

54 Using primitives: triangles and quads example DrawTriangleStrip Void DrawTriangleStrip() { // 3 rows of triangle strips for (int x = 0; x < 3; x++) { glbegin(gl_triangle_strip); for (int z = 0; z < 3; z++) { glvertex3f(x, 0.0, z); glvertex3f((x+1).0, 0, z); glvertex3f(x, 0.0, (z+1.0)); glvertex3f((x+1).0, 0, (z+1.0)); glend();

55 Using primitives: triangles and quads example DrawTriangleFan Void DrawTriangleFan() { glbegin(gl_triangle_fan); glvertex3f(0.0, 0.0, 0.0); // center vertex of fan for (int x = 4; x > 3; x--) // bottom side glvertex3f(x-1, 0.0, 3.0); for (int z = 4; z > 0; z--) // right side glvertex3f(3.0, 0.0, z-1); glend();

56 Using primitives: triangles and quads example DrawQuadStrip Void DrawQuadStrip() { for (int x = 0; x < 3; x++) { glbegin(gl_quad_strip); for (int z = 0; z < 4; z++) { glvertex3f(x, 0.0, z); glvertex3f((x+1).0, 0, z); glend(); }

57 Attributes Save and restore all of the state information for a group void glpushattrib(glbitfield mask); void glpopattrib(void);

58 Summary You learned A little more about the OpenGL state machine You know how to use glget( ) and glisenable( ) The primitive types supported by OpenGL How to modify properties Putting points, lines, triangles, and other primitives on the screen

59 On Your Own You have been tasked to write a function that draws a 2D circle approximation with the option of drawing only the edge of the circle or drawing the circle filled at the world origin (0, 0, 0) void DrawCircleApproximation(float radius, int numberofsides, bool edgeonly); radius: the radius of the circle numberofsides: a value for the number of edges in the circle approximation

60 Reference Dave Astle and Kevin Hawkins, Beginning OpenGL Game Programming, 1st Edition, Course Technology PTR,

三維繪圖程式設計 3D Graphics Programming Design 第七章基礎材質張貼技術嘉大資工系盧天麒

三維繪圖程式設計 3D Graphics Programming Design 第七章基礎材質張貼技術嘉大資工系盧天麒 三維繪圖程式設計 3D Graphics Programming Design 第七章基礎材質張貼技術嘉大資工系盧天麒 1 In this chapter, you will learn The basics of texture mapping Texture coordinates Texture objects and texture binding Texture specification

More information

三維繪圖程式設計 3D Graphics Programming Design 第六章 Bitmap 影像及圖檔格式設定嘉大資工系盧天麒

三維繪圖程式設計 3D Graphics Programming Design 第六章 Bitmap 影像及圖檔格式設定嘉大資工系盧天麒 三維繪圖程式設計 3D Graphics Programming Design 第六章 Bitmap 影像及圖檔格式設定嘉大資工系盧天麒 1 In this chapter, you will learn How to use OpenGL bitmaps OpenGL pixel functions How to load and save the Targa image format 2 The

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

Computer Graphics with OpenGL ES (J. Han) Chapter VII Rasterizer

Computer Graphics with OpenGL ES (J. Han) Chapter VII Rasterizer Chapter VII Rasterizer Rasterizer The vertex shader passes the clip-space vertices to the rasterizer, which performs the following: Clipping Perspective division Back-face culling Viewport transform Scan

More information

CSCI 4620/8626. Computer Graphics Attributes of Graphics Primitives (Chapter 5)

CSCI 4620/8626. Computer Graphics Attributes of Graphics Primitives (Chapter 5) CSCI 4620/8626 Computer Graphics Attributes of Graphics Primitives (Chapter 5) Last update: 2015-03-02 Non-Fill Methods While polygons can be filled (with patterns or colors), they can also be displayed

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

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

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

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

Drawing with OpenGL. Chapter 3. Chapter Objectives

Drawing with OpenGL. Chapter 3. Chapter Objectives Chapter 3 Drawing with OpenGL Chapter Objectives After reading this chapter, you will be able to: Identify all of the rendering primitives available in OpenGL. Initialize and populate data buffers for

More information

COMPUTER GRAPHICS LAB # 3

COMPUTER GRAPHICS LAB # 3 COMPUTER GRAPHICS LAB # 3 Chapter 2: COMPUTER GRAPHICS by F.S HILLs. Initial steps in drawing figures (polygon, rectangle etc) Objective: Basic understanding of simple code in OpenGL and initial steps

More information

Graphics Programming. August 31, Programming of the Sierpinski gasket. Programming with OpenGL and C/C++

Graphics Programming. August 31, Programming of the Sierpinski gasket. Programming with OpenGL and C/C++ Computer Graphics Graphics Programming August 31, 2005 Contents Our Goal in This Chapter Programming of the Sierpinski gasket How To? Programming with OpenGL and C/C++ OpenGL API (Application Programmer

More information

void drawdot(glint x, GLint y) { glbegin(gl_points); glvertex2i(x,y); glend();

void drawdot(glint x, GLint y) { glbegin(gl_points); glvertex2i(x,y); glend(); CSC 706 Computer Graphics Primitives, Stippling, Fitting In OpenGL Primitives Examples: GL_POINTS GL_LINES GL_LINE_STRIP GL_POLYGON GL_LINE_LOOP GL_ TRIANGLES GL_QUAD_STRIP GL_TRIANGLE_STRIP GL_TRIANGLE_FAN

More information

OpenGL Primitives. Examples: Lines. Points. Polylines. void drawdot(glint x, GLint y) { glbegin(gl_points); glvertex2i(x,y); glend(); }

OpenGL Primitives. Examples: Lines. Points. Polylines. void drawdot(glint x, GLint y) { glbegin(gl_points); glvertex2i(x,y); glend(); } CSC 706 Computer Graphics Primitives, Stippling, Fitting In Examples: OpenGL Primitives GL_POINTS GL_LINES LINES GL _ LINE _ STRIP GL_POLYGON GL_LINE_LOOP GL_TRIANGLES GL_QUAD_STRIP GL_TRIANGLE_STRIP GL_TRIANGLE_FAN

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

Lecture 3 Advanced Computer Graphics (CS & SE )

Lecture 3 Advanced Computer Graphics (CS & SE ) Lecture 3 Advanced Computer Graphics (CS & SE 233.420) Programming with OpenGL Program Structure Primitives Attributes and States Programming in three dimensions Inputs and Interaction Working with Callbacks

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

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

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

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

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

Computer Graphics Introduction to OpenGL

Computer Graphics Introduction to OpenGL Computer Graphics 2015 3. Introduction to OpenGL Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2015-09-28 2. 2D Graphics Algorithms (cont.) Rasterization Computer Graphics @ ZJU Hongxin Zhang,

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

Meshing and Geometry

Meshing and Geometry Meshing and Geometry Points in OpenGL glbegin(gl_points); glvertex2fv(p0); glvertex2fv(p1); p7 p0 p1 glvertex2fv(p2); glvertex2fv(p3); p6 p2 glvertex2fv(p4); glvertex2fv(p5); p5 p3 glvertex2fv(p6); glvertex2fv(p7);

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

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

This library uses only GL functions but contains code for creating common objects and simplifying viewing.

This library uses only GL functions but contains code for creating common objects and simplifying viewing. PES Institute of Technology, Bangalore South Campus (Formerly PES School of Engineering) (Hosur Road, 1KM before Electronic City, Bangalore-560 100) INTERNAL TEST (SCHEME AND SOLUTION) 1 Subject Name:

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

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

How shapes are represented in 3D Graphics. Aims and objectives By the end of the lecture you will be able to describe

How shapes are represented in 3D Graphics. Aims and objectives By the end of the lecture you will be able to describe Today s lecture Today we will learn about The mathematics of 3D space vectors How shapes are represented in 3D Graphics Modelling shapes as polygons Aims and objectives By the end of the lecture you will

More information

Building Models. Objectives. Introduce simple data structures for building polygonal models. OpenGL vertex arrays. Vertex lists Edge lists

Building Models. Objectives. Introduce simple data structures for building polygonal models. OpenGL vertex arrays. Vertex lists Edge lists Building Models Objectives Introduce simple data structures for building polygonal models Vertex lists Edge lists OpenGL vertex arrays 2 Representing a Mesh Consider a mesh v 5 v e e e 3 v 9 8 8 v e 4

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

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

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

CS 432 Interactive Computer Graphics

CS 432 Interactive Computer Graphics CS 432 Interactive Computer Graphics Lecture 2 Part 1 Primitives and Buffers Matt Burlick - Drexel University - CS 432 1 Rendering in OpenGL Ok, so now we want to actually draw stuff! OpenGL (like most

More information

Building Models. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Building Models. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico Building Models Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico 1 Objectives Introduce simple data structures for building polygonal

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

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

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

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

CS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008 CS559: Computer Graphics Lecture 2: OpenGL Transformation Li Zhang Spring 28 Today Transformation in OpenGL Reading Chapter 3 Last time Primitive Details glpolygonmode(glenum face, GLenum mode); face:

More information

Drawing Primitives. OpenGL basics

Drawing Primitives. OpenGL basics CSC 706 Computer Graphics / Dr. N. Gueorguieva 1 OpenGL Libraries Drawing Primitives OpenGL basics OpenGL core library OpenGL32 on Windows GL on most unix/linux systems (libgl.a) OpenGL Utility Library

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

6.837 Introduction to Computer Graphics Assignment 5: OpenGL and Solid Textures Due Wednesday October 22, 2003 at 11:59pm

6.837 Introduction to Computer Graphics Assignment 5: OpenGL and Solid Textures Due Wednesday October 22, 2003 at 11:59pm 6.837 Introduction to Computer Graphics Assignment 5: OpenGL and Solid Textures Due Wednesday October 22, 2003 at 11:59pm In this assignment, you will add an interactive preview of the scene and solid

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

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

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

The Rendering Pipeline (1)

The Rendering Pipeline (1) The Rendering Pipeline (1) Alessandro Martinelli alessandro.martinelli@unipv.it 30 settembre 2014 The Rendering Pipeline (1) Rendering Architecture First Rendering Pipeline Second Pipeline: Illumination

More information

Fundamentals of Computer Graphics. Lecture 3 Generate a simple shape using OpenGL. Yong-Jin Liu

Fundamentals of Computer Graphics. Lecture 3 Generate a simple shape using OpenGL. Yong-Jin Liu Fundamentals of Computer Graphics Lecture 3 Generate a simple shape using OpenGL Yong-Jin Liu What is this course about? Generate an element shape point, line, region OpenGL command Window based programming

More information

4: Polygons and pixels

4: Polygons and pixels COMP711 Computer Graphics and Image Processing 4: Polygons and pixels Toby.Howard@manchester.ac.uk 1 Introduction We ll look at Properties of polygons: convexity, winding, faces, normals Scan conversion

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

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

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

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

Modeling. Simulating the Everyday World

Modeling. Simulating the Everyday World Modeling Simulating the Everyday World Three broad areas: Modeling (Geometric) = Shape Animation = Motion/Behavior Rendering = Appearance Page 1 Geometric Modeling 1. How to represent 3d shapes Polygonal

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

Simple Geometric Modeling

Simple Geometric Modeling Simple Geometric Modeling Prerequisites This module requires an understanding of simple 3-dimensional geometry, knowledge of how to represent points in 3-space, and enough programming experience to be

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

Computer Graphics Introduction to OpenGL

Computer Graphics Introduction to OpenGL Computer Graphics 2013 3. Introduction to OpenGL Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2013-09-16 2. 2D Graphics Algorithms (cont.) Rasterization Scan converting lines start

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

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

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

Time: 3 hours Max. Marks: 80. Note: Answer FIVE full questions, choosing one full question from each module.

Time: 3 hours Max. Marks: 80. Note: Answer FIVE full questions, choosing one full question from each module. USN 6 th Semester CBCS Scheme Model Question Paper 1 Department of Computer Science and Engineering, C. Byregowda Institute of Technology Computer Graphics and Visualization Time: 3 hours Max. Marks: 80

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

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

CSCI E-74. Simulation and Gaming

CSCI E-74. Simulation and Gaming CSCI E-74 Virtual and Augmented Reality for Simulation and Gaming Fall term 2017 Gianluca De Novi, PhD Lesson 3 General Introduction to OpenGL APIs and TRS Perspective Simulation Perspective simulation

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

Introduction to OpenGL and 3D Graphics

Introduction to OpenGL and 3D Graphics Introduction to OpenGL and 3D Graphics Categories Introduction to graphics The History of 3D Graphics How 3D Graphics work Drawing Points, Lines and Polygons in OpenGL Transformations and Perspective Introduction

More information

CS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II. Emmanuel Agu

CS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II. Emmanuel Agu CS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II Emmanuel Agu Recall: OpenGL Skeleton void main(int argc, char** argv){ // First initialize toolkit, set display mode and create window glutinit(&argc,

More information

CSCI 4620/8626. Coordinate Reference Frames

CSCI 4620/8626. Coordinate Reference Frames CSCI 4620/8626 Computer Graphics Graphics Output Primitives Last update: 2014-02-03 Coordinate Reference Frames To describe a picture, the world-coordinate reference frame (2D or 3D) must be selected.

More information

6. Make use of glviewport() to display two sine curves on the same screen, one on the

6. Make use of glviewport() to display two sine curves on the same screen, one on the Duc Nguyen CSE-420: Computer Graphics 10/17/18 1. Modify lines.cpp to display lines in the following patterns: a. a long dash and a dot, (.. ) b. two close dots followed by a distant dot (...... ) 2. Modify

More information

to OpenGL Introduction Pipeline Graphics pipeline OpenGL pipeline OpenGL syntax Modeling Arrays Conclusion 1 Introduction Introduction to OpenGL

to OpenGL Introduction Pipeline Graphics pipeline OpenGL pipeline OpenGL syntax Modeling Arrays Conclusion 1 Introduction Introduction to OpenGL to to ning Lecture : introduction to Lab : first steps in and - 25/02/2009 Lecture/Lab : transformations and hierarchical - 04/03/2009 to Lecture : lights and materials in - 11/03/2009 Lab : lights 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

Screen Space & World Space

Screen Space & World Space CS380: Computer Graphics Screen Space & World Space Sung-Eui Yoon ( 윤성의 ) Course URL: http://sglab.kaist.ac.kr/~sungeui/cg Class Objectives Understand different spaces and basic OpenGL commands Understand

More information

Image Processing. Geometry Processing. Reading: (Not really covered in our text. See Sects 18.1, 18.2.) Overview: Display

Image Processing. Geometry Processing. Reading: (Not really covered in our text. See Sects 18.1, 18.2.) Overview: Display CMSC 427: Chapter 2 Graphics Libraries and OpenGL Reading: (Not really covered in our text. See Sects 18.1, 18.2.) Overview: Graphics Libraries OpenGL and its Structure Drawing Primitives in OpenGL GLUT

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

Chapter 3: Graphics Output Primitives. OpenGL Line Functions. OpenGL Point Functions. Line Drawing Algorithms

Chapter 3: Graphics Output Primitives. OpenGL Line Functions. OpenGL Point Functions. Line Drawing Algorithms Chater : Grahics Outut Primitives Primitives: functions in grahics acage that we use to describe icture element Points and straight lines are the simlest rimitives Some acages include circles, conic sections,

More information

Computer Graphics Introduction to OpenGL

Computer Graphics Introduction to OpenGL ! Computer Graphics 2014! 3. Introduction to OpenGL Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2014-09-29! ! 2. 2D Graphics Algorithms (cont.) Rasterization Scan converting lines

More information

Filled Area Primitives. CEng 477 Introduction to Computer Graphics METU, 2007

Filled Area Primitives. CEng 477 Introduction to Computer Graphics METU, 2007 Filled Area Primitives CEng 477 Introduction to Computer Graphics METU, 2007 Filled Area Primitives Two basic approaches to area filling on raster systems: Determine the overlap intervals for scan lines

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

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CSE528 Computer Graphics: Theory, Algorithms, and Applications CSE528 Computer Graphics: Theory, Algorithms, and Applications Hong Qin State University of New York at Stony Brook (Stony Brook University) Stony Brook, New York 11794--4400 Tel: (631)632-8450; Fax: (631)632-8334

More information

Computer Graphics Introduction to OpenGL

Computer Graphics Introduction to OpenGL Computer Graphics 2016 3. Introduction to OpenGL Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2016-10-10 2. 2D Graphics Algorithms (cont.) 3 Rasterization Computer Graphics @ ZJU 4 5 6 7

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

CS Computer Graphics: OpenGL, Continued

CS Computer Graphics: OpenGL, Continued CS 543 - Computer Graphics: OpenGL, Continued by Robert W. Lindeman gogo@wpi.edu (with help from Emmanuel Agu ;-) Last time. OpenGL set up Basic structure OpenGL skeleton Callback functions, etc. R.W.

More information

CS Computer Graphics: OpenGL, Continued

CS Computer Graphics: OpenGL, Continued CS 543 - Computer Graphics: OpenGL, Continued by Robert W. Lindeman gogo@wpi.edu (with help from Emmanuel Agu ;-) Last time. OpenGL set up Basic structure OpenGL skeleton Callback functions, etc. R.W.

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

CSE 167: Introduction to Computer Graphics Lecture #5: Illumination Model

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

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

polygon meshes polygon meshes representation

polygon meshes polygon meshes representation polygon meshes computer graphics polygon meshes 2009 fabio pellacini 1 polygon meshes representation which representation is good? often triangles/quads only will work on triangles compact efficient for

More information

Normalized Device Coordinate System (NDC) World Coordinate System. Example Coordinate Systems. Device Coordinate System

Normalized Device Coordinate System (NDC) World Coordinate System. Example Coordinate Systems. Device Coordinate System World Coordinate System Normalized Device Coordinate System (NDC) Model Program Graphics System Workstation Model Program Graphics System Workstation Normally, the User or Object Coordinate System. World

More information

Computer Graphics. Chapter 4 Attributes of Graphics Primitives. Somsak Walairacht, Computer Engineering, KMITL 1

Computer Graphics. Chapter 4 Attributes of Graphics Primitives. Somsak Walairacht, Computer Engineering, KMITL 1 Computer Graphics Chapter 4 Attributes of Graphics Primitives Somsak Walairacht, Computer Engineering, KMITL 1 Outline OpenGL State Variables Point Attributes Line Attributes Fill-Area Attributes Scan-Line

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

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

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

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

World Coordinate System

World Coordinate System World Coordinate System Application Model Application Program Graphics System Workstation Normally, the User or Object Coordinate System. World Coordinate Window: A subset of the world coordinate system,

More information

Computer Graphics. This Week. Meshes. Meshes. What is a Polygon Mesh? Meshes. Modelling Shapes with Polygon Meshes.

Computer Graphics. This Week. Meshes. Meshes. What is a Polygon Mesh? Meshes. Modelling Shapes with Polygon Meshes. 1 This Week Computer Graphics Modeling Shapes Modelling Shapes with Polygon Solid Modelling Extruded Shapes Mesh Approximations 2 What is a Polygon Mesh? A surface made up of a collection of polygon faces.

More information

CS 465 Program 4: Modeller

CS 465 Program 4: Modeller CS 465 Program 4: Modeller out: 30 October 2004 due: 16 November 2004 1 Introduction In this assignment you will work on a simple 3D modelling system that uses simple primitives and curved surfaces organized

More information

GLUT. What is OpenGL? Introduction to OpenGL and GLUT

GLUT. What is OpenGL? Introduction to OpenGL and GLUT What is OpenGL? Introduction to OpenGL and An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality h color images composed of geometric and image primitives

More information

Polygonal Meshes: Representing 3D Objects

Polygonal Meshes: Representing 3D Objects Polygonal Meshes: Representing 3D Objects Real world modeling requires representation of surfaces Two situations: 1. Model an existing object Most likely can only approximate the object Represent all (most)

More information