Curso: Graficación Prof. Gueorgi Khatchatourov

Slides:



Advertisements
Similar presentations
OpenGL: Simple Use Open a window and attach OpenGL to it Set projection parameters (e.g., field of view) Setup lighting, if any Main rendering loop –Set.
Advertisements

CMPE 466 COMPUTER GRAPHICS
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
1 Building Models. 2 Objectives Introduce simple data structures for building polygonal models ­Vertex lists ­Edge lists OpenGL vertex arrays.
2IV60 Computer graphics Graphics primitives and attributes Jack van Wijk TU/e.
Chapter 3. Drawing primitives in Space Presented by Garrett Yeh.
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
CSCE 441: Computer Graphics Scan Conversion of Polygons
Drawing Geometric Objects
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D.
OpenGL and WebGL Drawing Functions CSCI 440 Day Five.
CSC 461: Lecture 6 1 CSC461 Lecture 6: 2D Programming in OpenGL Objectives:  Fundamental OpenGL primitives  Attributes  Viewport.
Computer Graphics CS 385 February 7, Fundamentals of OpenGl and Glut Today we will go through the basics of a minimal OpenGl Glut project, explaining.
Reference1. [OpenGL course slides by Rasmus Stenholt]
CAP 4703 Computer Graphic Methods Prof. Roy Levow Lecture 2.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
JOGL in MS Windows GDI – Graphics Device Interface (Windows-specific) OpenGL Lib JOGL Commands GDI Processor Graphics Hardware JOGL Lib.
COS 397 Computer Graphics Assoc. Prof. Svetla Boytcheva AUBG 2013 COS 397 Computer Graphics Practical Session №1 Introduction to OpenGL, GLFW and CG.
Basic OpenGL Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, September 10, 2003.
Drawing Basic Graphics Primitives Lecture 4 Wed, Sep 3, 2003.
CSE 470: Computer Graphics. 10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.
State Management and Drawing Geometry Objects
Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition Chapter 2.
P RACTICING O PEN GL- P RIMITIVES. O PEN GL O UTPUT P RIMITIVES  Each geometric object is described by a set of vertices and the type of primitive to.
Period 5 Nathan Rodriguez. -Point  a geometric element that has position but no extension; "a point is defined by its coordinates"
Computer Graphics Bing-Yu Chen National Taiwan University.
Intro to OpenGL: Vertices and Drawing
UniS CS297 Graphics with Java and OpenGL State Management and Drawing Primative Geometric Objects.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 CSCE 441 Lecture 2: Scan Conversion of Lines Jinxiang Chai.
What are Computer Graphics Basically anything that is on you Monitor – This includes the text that you will see Text isn’t Advanced Graphics But…. Understanding.
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 4: Color and Attributes Isaac Gang University.
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 15 Creating 3D Models.
OpenGL: Introduction #include main() { OpenWindow() ; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0,
2002 by Jim X. Chen: Drawing Geometric Models.1. Objectives –OpenGL drawing primitives and attributes –OpenGL polygon face.
CIS 681 Review: OpenGL. CIS 681 Command Syntax OpenGL commands start with a gl. This is followed by the base command such as Color. Followed by the number.
Chapter 10 Geometry Part 1. 1.Polygons on a Coordinate Grid 2.Nets of Polyhedrons 3.Surface Area of Polyhedrons 4.Surface Area Continued 5.Spring Break.
Vocabulary for the Common Core Sixth Grade.  base: The side of a polygon that is perpendicular to the altitude or height. Base of this triangle Height.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
OpenGL CS418 Computer Graphics John C. Hart. OpenGL Based on GL (graphics library) by Silicon Graphics Inc. (SGI) Advantages: Runs on everything, including.
Computer Graphics Lecture 34. OpenGL Programming II Taqdees A. Siddiqi
OpenGL Programming Guide Chapter 2 Korea Univ. Graphics Labs. Ji Jun Yong Korea Univ. Graphics Labs. Ji Jun Yong.
CSC Graphics Programming
Programming with OpenGL Part 2: Complete Programs
Materi Anatomi OpenGL Fungsi GLUT Posisi Kamera Proyeksi
OpenGL API 2D Graphic Primitives
Programming with OpenGL Part 2: Complete Programs
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
Class 17 front and back lighting convex sets, convex hull
Lab 3 Geometric Drawing Lab 3 Geometric Drawing.
Objectives OpenGL drawing primitives and attributes
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 4: Color and Attributes
CSE 411 Computer Graphics Lecture #3 Graphics Output Primitives
Drawing in the plane 455.
Primitive Objects Lecture 6 Wed, Sep 5, 2007.
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
OpenGL program.
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 4: Color and Attributes
Programming with OpenGL Part 2: Complete Programs
Class 18 front and back lighting convex sets, convex hull
Polygons.
Presentation transcript:

Curso: Graficación Prof. Gueorgi Khatchatourov OpenGL Primitives Curso: Graficación Prof. Gueorgi Khatchatourov

OpenGL Primitives back The Vertex–A Position in Space A vertex = a coordinate in 2D or 3D space. The geometric definition of a vertex is not just a point in space, but rather the point at which an intersection of two lines or curves occurs. This is the essence of primitives. In both 2D and 3D, when you draw an object, you actually compose it with several smaller shapes called primitives. A primitive is simply the interpretation of a set or list of vertices into some shape drawn on the screen. There are 10 primitives in OpenGL, from a simple point drawn in space to a closed polygon of any number of sides. Primitives are one- or two-dimensional entities or surfaces such as points, lines, and polygons (a flat, multisided shape) that are assembled in 3D space to create 3D objects. For example, a three-dimensional cube consists of six two-dimensional squares, each placed on a separate face. Each corner of the square (or of any primitive) is represented by a vertex.

Guía de los tipos geométricos primitivos (ver la tabla de Geometric Primitive Types) Puntos(Vertices) Líneas Triángulos Cuadrilaterales Polígonos

Ir a la guía Specificar un vertice (I de V): ejemplos The point (50,50,0) as specified by glVertex3f(50.0f, 50.0f, 0.0f). Two other forms of glVertex take two glVertex2f(50.0f, 50.0f); and four arguments, respectively, glVertex4f(50.0f, 50.0f, 0.0f, 1.0f). The two commands glVertex2i(1, 3) and glVertex2f(1.0, 3.0) are equivalent, except that the first specifies the vertex's coordinates as 32-bit integers, and the second specifies them as single-precision floating-point numbers.

Ir a la guía Specificar un vertice (II de V): cómo se interpretan los vértices cuatro dimensionales

Ir a la guía Specificar un vertice (III de V): sintaxis glVertex*v() refers to all the vector versions of the command you use to specify vertices. void glVertex{234}{sifd}[v](TYPEcoords); Specifies a vertex for use in describing a geometric object. You can supply up to four coordinates (x, y, z, w) for a particular vertex or as few as two (x, y) by selecting the appropriate version of the command. If you use a version that doesn't explicitly specify z or w, z is understood to be 0 and w is understood to be 1. Calls to glVertex*() are only effective between a glBegin() and glEnd() pair.

Ir a la guía Specificar un vertice (IV de V):dibujar puntos glBegin(GL_POINTS); // Select points as the primitive glVertex3f(0.0f, 0.0f, 0.0f); // Specify a point glVertex3f(50.0f, 50.0f, 50.0f); // Specify another point glEnd(); // Done drawing points

Ir a la guía Specificar un vertice (V de V): Establecer tamaño del punto void glPointSize(GLfloat size); The glPointSize function takes a single parameter that specifies the approximate diameter in pixels of the point drawn. Not all point sizes are supported, however, and you should make sure the point size you specify is available. Use the following code to get the range of point sizes and the smallest interval between them: GLfloat sizes[2]; // Store supported point size range GLfloat step; // Store supported point size increments // Get supported point size range and step size glGetFloatv(GL_POINT_SIZE_RANGE,sizes); glGetFloatv(GL_POINT_SIZE_GRANULARITY,&step);

Ir a la guía Dibujar líneas (I de VI) glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(50.0f, 50.0f, 50.0f); glEnd();

Ir a la guía Dibujar líneas (II de VI): uso del ciclo para construir varias líneas glBegin(GL_LINES); // All lines lie in the xy plane. z = 0.0f; for(angle = 0.0f; angle <= GL_PI; angle += (GL_PI/20.0f)) { // Top half of the circle x = 50.0f*sin(angle); y = 50.0f*cos(angle); glVertex3f(x, y, z); // First endpoint of line // Bottom half of the circle x = 50.0f*sin(angle + GL_PI); y = 50.0f*cos(angle + GL_PI); glVertex3f(x, y, z); // Second endpoint of line } // Done drawing points glEnd();

Ir a la guía Dibujar líneas (III de VI): Líneas encadenadas abiertas (strips) y cerradas (loops) glBegin(GL_LINE_STRIP); glVertex3f(0.0f, 0.0f, 0.0f); // V0 glVertex3f(50.0f, 50.0f, 0.0f); // V1 glVertex3f(50.0f, 100.0f, 0.0f); // V2 glEnd(); glBegin(GL_LINE_LOOP);

Ir a la guía Dibujar líneas (IV de VI): Establecer grosor de la línea void glLineWidth(GLfloat width); The glLineWidth function takes a single parameter that specifies the approximate width, in pixels, of the line drawn. Just like point sizes, not all line widths are supported, and you should make sure the line width you want to specify is available. Use the following code to get the range of line widths and the smallest interval between them: Use the following code to get the range of point sizes and the smallest interval between them: GLfloat sizes[2]; // Store supported line width range GLfloat step; // Store supported line width increments // Get supported line width range and step size glGetFloatv(GL_LINE_WIDTH_RANGE,sizes); glGetFloatv(GL_LINE_WIDTH_GRANULARITY,&step);

Ir a la guía Dibujar líneas (V de VI): Establecer un patrón de línea salpicada (line stippling) (I) In addition to changing line widths, you can create lines with a dotted or dashed pattern, called stippling. To use line stippling, you must first enable stippling with a call to glEnable(GL_LINE_STIPPLE); Then the function glLineStipple establishes the pattern that the lines use for drawing: void glLineStipple(GLint factor, GLushort pattern);

Ir a la guía Dibujar líneas (VI de VI): Establecer un patrón de línea salpicada (line stippling) (II) The pattern parameter is a 16-bit value that specifies a pattern to use when drawing the lines. Each bit represents a section of the line segment that is either on or off. By default, each bit corresponds to a single pixel, but the factor parameter serves as a multiplier to increase the width of the pattern. For example, setting factor to 5 causes each bit in the pattern to represent five pixels in a row that are either on or off. Furthermore, bit 0 (the least significant bit) of the pattern is used first to specify the line. Figure illustrates a sample bit pattern applied to a line segment.

Ir a la guía Dibujar triángulos(I de IV) glBegin(GL_TRIANGLES); glVertex2f(0.0f, 0.0f); // V0 glVertex2f(25.0f, 25.0f); // V1 glVertex2f(50.0f, 0.0f); // V2 glVertex2f(-50.0f, 0.0f); // V3 glVertex2f(-75.0f, 50.0f); // V4 glVertex2f(-25.0f, 0.0f); // V5 glEnd();

Ir a la guía Dibujar triángulos(II de IV): Notas: Color y orientación de triángulo The triangles will be filled with the currently selected drawing color. If you don't specify a drawing color at some point, you can't be certain of the result. An important characteristic of any polygonal primitive is illustrated in Figura relacionada a la orienta.... Notice the arrows on the lines that connect the vertices. When the first triangle is drawn, the lines are drawn from V0 to V1, then to V2, and finally back to V0 to close the triangle. This path is in the order that the vertices are specified, and for this example, that order is clockwise from your point of view. The same directional characteristic is present for the second triangle as well.

Ir a la guía Dibujar triángulos(III de IV): Tiras formados de triángulos: (Triangle Strips) glBegin(GL_TRIANGLE_STRIP); ……………….. glEnd(); Draws a series of triangles (three-sided polygons) using vertices v0, v1, v2, then v2, v1, v3 (note the order), then v2, v3, v4, and so on. The ordering is to ensure that the triangles are all drawn with the same orientation so that the strip can correctly form part of a surface. Preserving the orientation is important for some operations, such as culling. n must be at least 3 for anything to be drawn.

Ir a la guía Dibujar triángulos(IV de IV): Abanicos formados de triángulos: (Triangle Fans) glBegin(GL_TRIANGLE_FAN); glVertex3f(0.0f, 0.0f, 75.0f); // Pinnacle of cone is shared vertex for fan, moved up z-axis // Loop around in a circle and specify even points along the circle // as the vertices of the triangle fan for(angle = 0.0f; angle < (2.0f*GL_PI); angle += (GL_PI/8.0f)) { // Calculate x and y position of the next vertex x = 50.0f*sin(angle); y = 50.0f*cos(angle); // Alternate color between red and green if((iPivot %2) == 0) glColor3f(0.0f, 1.0f, 0.0f); else glColor3f(1.0f, 0.0f, 0.0f); iPivot++; // Increment pivot to change color next time glVertex2f(x, y); // Specify the next vertex for the triangle fan } glEnd(); // Done drawing fan for cone

Regresar a Notas: Color y orientación de triángulo Regresar a Notas: Color y orientación de triángulo. Figura relacionada a la orientación de triángulos

Regresar a “line stippling” Figura: Un patrón para construir segmento de una linea salpicada Ver mas opciones

Regresar a “line stippling” Figura: Más patrones para construir segmento de una linea salpicada Where pattern and factor are parameters of glLineStipple(): void glLineStipple(GLint factor, GLushort pattern);

Ir a la guía Table: Geometric Primitive Names and Meanings Value Meaning GL_POINTS individual points GL_LINES pairs of vertices interpreted as individual line segments GL_LINE_STRIP series of connected line segments GL_LINE_LOOP same as above, with a segment added between last and first vertices GL_TRIANGLES triples of vertices interpreted as triangles GL_TRIANGLE_STRIP linked strip of triangles GL_TRIANGLE_FAN linked fan of triangles GL_QUADS quadruples of vertices interpreted as four-sided polygons GL_QUAD_STRIP linked strip of quadrilaterals GL_POLYGON boundary of a simple, convex polygon