Anúncio

3 CG_U1_P2_PPT_3 OpenGL.pptx

22 de Mar de 2023
Anúncio

Mais conteúdo relacionado

Anúncio

3 CG_U1_P2_PPT_3 OpenGL.pptx

  1. •OpenGL, stand for "Open Graphics Library,” •OpenGL is a software interface that allows the programmer to create 2D and 3D graphics images. •It is Language independent •It is Platform independent •OpenGL is a software interface to graphics hardware. •This interface consists of about 150 distinct commands that you use to specify the objects and operations needed to produce interactive three-dimensional applications. ●OpenGL is designed as a streamlined, hardware-independent interface to be implemented on many different hardware platforms. ●To achieve these qualities, no commands for performing windowing tasks or obtaining user input are included in OpenGL; instead, you must work through whatever windowing system controls the particular hardware you’re using.
  2. OpenGL architecture : The OpenGL architecture is structured as pipeline.. Commands enter in the pipeline from the left.
  3. 1) Display list : ● Commands may either be accumulated in display lists, or processed immediately through the pipeline. ● Display lists allow for greater optimization and command reuse, but not all commands can be put in display lists. 1) Evaluator : The first stage in the pipeline is the evaluator. This stage effectively takes any polynomial evaluator commands and evaluates them into their corresponding vertex and attribute commands. 2) per-vertex operations : The second stage is the per-vertex operations, including transformations, lighting, clipping , and viewport mapping.
  4. 4) Rasterization : ● It is converting a vector image (a mathematically defined image of points and curves) to a raster image (a picture composed of discrete pixels). ● Rasterization is commonly used in real-time 3D graphics processing to convert images quickly for display on a computer monitor.
  5. 5) Per-fragment operations : The fourth stage is the per-fragment operations. Before fragments go to the framebuffer, they may be subjected to a series of conditional tests and modifications, such as blending or z-buffering. 6) Frame buffer : A frame buffer is a large, contiguous piece of computer memory. Picture related information stored in a frame buffer. At a minimum there is one memory bit for each pixel. Parts of the framebuffer may be fed back into the pipeline as pixel rectangles. 7) Texture memory is a type of digital storage that makes texture data readily available.Texture memory may be used in the rasterization process
  6. Clipping The primary use of clipping in computer graphics is to remove objects, lines, or line segments that are outside the viewing pane.
  7. Window to Viewport Transformation It is the process of transforming a 2D world-coordinate objects to device coordinates.
  8. Color Blending : Color blending is a way to mix two colors together to produce to third color.
  9. Z-buffer : Z-buffer, which is also known as the Depth-buffer method is one of the commonly used method for hidden surface detection.
  10. Construct shapes from geometric primitives, thereby creating mathematical descriptions of objects. (OpenGL considers points, lines, polygons, images, and bitmaps to be primitives.) Arrange the objects in three-dimensional space and select the desired vantage point for viewing the composed scene. Calculate the color of all the objects. The color might be explicitly assigned by the application, determined from specified lighting conditions, obtained by pasting a texture on to the objects, or some combination of these three actions. Convert the mathematical description of objects and their associated color information to pixels on the screen. This process is called rasterization. Operations Carried out by OpenGL:
  11. Geometric Primitives Points Coordinate s Size Lines Vertices Width Stippling Polygons Vertices Outline/solid Normals
  12. OpenGL Primitives : ● In OpenGL, an object is made up of geometric primitives such as triangle, quad, line segment and point. ● A primitive is made up of one or more vertices. OpenGL supports the following primitives 1) GL_POINTS ● Treats each vertex as a single point. ● Vertex n defines a point n. ● N points are drawn.
  13. 2) GL_LINES ● Treats each pair of vertices as an independent line segment.
  14. 3) GL_LINE_STRIP ● Draws a connected group of line segments from the first vertex to the last.
  15. 4) GL_LINE_LOOP ● Draws a connected group of line segments from the first vertex to the last, then back to the first.
  16. 5) GL_TRIANGLES ● Treats each triplet of vertices as an independent triangle.
  17. 6) GL_TRIANGLE_STRIP ● Draws a connected group of triangles.
  18. 7) GL_TRIANGLE_FAN ● Draws a connected group of triangles that fan around a central point.
  19. 8) GL_QUADS ● Treats each group of four vertices as an independent quadrilateral.
  20. 9) GL_QUAD_STRIP ● Draws a connected group of quadrilaterals.
  21. 9) GL_Polygon ● Draw a polygon
  22. Sample code glBegin(GL_POLYGON); glVertex3fv(p1); glVertex3fv(p2); glVertex3fv(p3); glVertex3fv(p4); glEnd();
  23. Attributes •An attribute is any property that determines how a geometric primitives is to be rendered •Each time, OpenGL processes a vertex, it uses data stored in its internal attribute tables to determine how the vertex should be transformed, rendered or any of OpenGL’s other modes glPointSize(3.0); glShadeModel(GL_SMOOTH); glBegin(GL_LINE); glColor4f(1.0, 1.0, 1.0, 1.0); glVertex2f(5.0, 5.0); glColor3f(0.0, 1.0, 0.0); glVertex2f(25.0, 5.0); glEnd();
  24. OpenGL Functions Primitive functions : Defines low level objects such as points, line segments, polygons etc. Attribute functions : Attributes determine the appearance of objects  Color (points, lines, polygons)  Size and width (points, lines)  Polygon mode : • Display as filled • Display edges • Display vertices Viewing functions: Allows us to specify various views by describing the camera’s position and orientation. Transformation functions :Provides user to carry out transformation of objects like rotation, scaling etc. Input functions: Allows us to deal with a diverse to finput devices like keyboard, mouse etc Control functions: Enables us to initialize our programs, helps in dealing with any errors during execution of the program. Query functions: Helps querying formation about the properties of the particular implementation.
  25. OpenGL Functions Control Functions (interaction with windows) Window–A rectangular area of our display. Modern systems allow many windows to be displayed on the screen (multi window environment). The position of the window is with reference to the origin. The origin(0,0) is the top left corner of the screen. glutInit allows application to get command line arguments and initializes system gluInitDisplayMode requests properties for the window (the rendering context) • RGBcolor • Singlebuffering • Properties logically OR edtogether glutWindowSize in pixels glutWindowPosition from top-left corner of display glutCreateWindow create window with a particular title
  26. Libraries to Include ● GL, for which the commands begin with GL; ● GLUT, the GL Utility Toolkit, opens windows, develops menus, and manages events. ● GLU, the GL Utility Library, which provides high level routines to handle complex mathematical and drawing operations. ● GLUI, the User Interface Library, which is completely integrated with the GLUT library. ○ The GLUT functions must be available for GLUI to operate properly. ○ GLUI provides sophisticated controls and menus to OpenGL applications.
Anúncio