2. OpenGL ( Open Graphics Library )
• Is a cross-language, cross-platformAPI for rendering 2D and 3D
vector graphics.The API is typically used to interact with a graphics
processing unit (GPU), to achieve hardware-accelerated rendering
• the people who make GPUs, are responsible for writing
implementations of the OpenGL rendering system.Their
implementations, commonly called "drivers“ , translate OpenGL API
commands into GPU commands
3. OpenGL History
• Development started by SGI (Silicon Graphics INC.) at 1991 (
developers groups name was ARB ( IBM , Microsoft , Nvidia , … )
• First release at 1992 ( OpenGL 1.0 )
• Last release by SGI at 2 July 2006 ( OpenGL 2.1 )
• Maintainer changed at July 2006 ( from SGI to Khronos Group( SGI ,
ATI , Nvidia , … ) )
• First big release by Khronos at 11 Agust 2008 ( OpenGL 3.0 )
• Last release by Khronos at 31 July 2017 ( OpenGL 4.6 )
9. Some questions
• What is GPU ?
Like CPUs , GPUs are processors , but for huge processes like
rendering
• What is Rendering ?
Rendering means the process of translating 2D or 3D geometry to raster
Image
• Is GPU only for rendering ?
Of course not , GPGPU ( general purpose graphics processing
unit ) , is the use of a GPU to perform computation in
applications traditionally handled by the CPU
10. Some questions
• CPU vs GPU ?
As we know CPUs are devided by brands (Intel , AMD , …) , ISAs
(CISC , RISC , ZISC , MISC , …) , … , GPUs can be devided by
parameters such brands ( Nvidia , Intel , AMD , … ) ,
Architectures (Kepler , Maxwell , Pascal ,Volta , … ) and etc
• Can we write an application for GPU ?
Like CPUs that have compiler ( translating high-level language
to assembly ( clang , gcc , cc , … ) ) and assembler ( translate
assembly to machine code ( nasm , yasm , … ) ) , GPUs are
programmable , too and have compiler ( nvcc , hcc , … ) and
assembler ( gcnasm , asfermi , … )
• What is OpenGL for ?
For writing applications with interacting to GPU for rendering , we
need deep knowledge about our GPU Architecture and hardware to
create a simple application , renders a model , so OpenGL is a higher
level API for simple interacting with GPU
12. OpenGL rendering pipeline
• At the first level OpenGL gets vertex array of our model and
our texture coordinates or ( color and coordinates )
• At the second level OpenGL will translate , rotate , scale our
vertices based on the transformation and perspective
matrices ( position calculator )
• At the third level OpenGL assembles our vertices into
triangles based on primitive type
• At the fourth level OpenGL rasterizes our triangles into pixel
format based on view port matrices and
• At the fifth level OpenGL will colorize and texturize our pixels (
called fragment shader or pixel shader ) ( color chooser )
• At the sixth level OpenGL will test our pixels and do some
blending operations and at the end will write pixels into
framebuffer for showing in display
13. OpenGL rendering pipeline
Vertex shader ( position calculator )
Fragment shader (color chooser )
Another simple view of OpenGL pipeline
17. Testing ?
Some time’s OpenGL may fail to
rendering correctly like this picture
The DepthTest is a per-sample
processing operation performed
after the Fragment Shader for
detecting incorrect frames and
discarding them .
18. An important question !
How can you render this simple wall ? How many
triangles you need to render it ? 100 ? 1000 ? Millions ?
Oh is wrong to use Millions of triangles for rendering a
simple wall !
So how can you ?
Of course ! Textures
You can use a simple rectangle and map this image on
it ( called texture mapping )