![]() Instead of using a single frame buffer, modern GPU uses two of them: a front buffer and a back buffer. ![]() This could be resolved by using so-called double buffering. This would result in the so-called tearing, in which the screen shows parts of the old frame and parts of the new frame. While the display is reading from the frame buffer to display the current frame, we might be updating its contents for the next frame (not necessarily in raster-scan manner). This is known as the refresh rate.Ī complete screen image is called a frame. The display refreshes its screen several dozen times per second, typically 60Hz for LCD monitors and higher for CRT tubes. ![]() The display reads the color values from the frame buffer row-by-row, from left-to-right, top-to-bottom, and puts each of the values onto the screen. The GPU writes the color value into the frame buffer. The color values of the pixels are stored in a special part of graphics memory called frame buffer. The number of rows by columns of the rectangular grid is called the resolution of the display, which can range from 640x480 (VGA), 800圆00 (SVGA), 1024x768 (XGA) to 1920x1080 (FHD), or even higher. The number of color-bits per pixel is called the depth (or precision) of the display. This is different from the conventional 2D Cartesian coordinates, where y-axis is pointing upwards. The origin (0, 0) is located at the top-left corner, with x-axis pointing right and y-axis pointing down. The position is expressed in terms of (x, y) coordinates. Color is expressed in RGB (Red-Green-Blue) components - typically 8 bits per component or 24 bits per pixel (or true color). A pixel has two properties: a color and a position. A raster is a 2D rectangular grid of pixels (or picture elements). Pixels and FrameĪll modern displays are raster-based. Modern day computer has dedicated Graphics Processing Unit (GPU) to produce images for the display, with its own graphics memory (or Video RAM or VRAM). Each vertex from our figure has a position attribute, let’s ignore for the moment any other possible attribute like a color.Computer Graphics Hardware GPU (Graphics Processing Unit) In the above figure we have four triangles and twelve vertices. In OpenGL terminology, a vertex can be seen as a collection of attributes like position, color, texture coordinates etc … For now, let’s try to draw the four triangles from the next figure:įrom a geometrical point of view, a triangle is completely defined by the position in space of his three corners or vertices. ![]() The basic geometrical primitives that the core OpenGL profile provide to us are points, lines and triangles.įor simplicity, we are going to use only two dimensional drawings in this article, but keep in mind that OpenGL allows us to represent three dimensional objects, more on this in a future article. It is the programmer’s job to combine the geometrical primitives from OpenGL in complex shapes and bodies. ![]() It is time to actually draw something using OpenGL.įirst, let me mention that OpenGL is a low level API, this means that it has no support for drawing complex geometrical objects. In the first article we’ve seen how to open a window for our OpenGL application with the GLFW library and how to compile and run the code on Windows, OS X and Linux. This is the second article from my OpenGL 101 series. Solarian Programmer My programming ramblings Home Archives Contact Privacy OpenGL 101: Drawing primitives - points, lines and triangles Posted on by Paul ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |