0
$\begingroup$

I am sorry if the question is too basic but I am just starting with the graphics library. My question is when I invoke draw API in openGL who does the actual job of drawing/coloring of the actual pixels on the screen?

Does openGL has library implementation of draw that sends the instructions on how to draw shapes? or draw API hits the graphics processing unit of the computer eg Intel graphics or Nvidia graphics and it is the job of theirs to actually draw the content on screen. Is it them who has the API which ultimately gets hit when a draw API gets called?

How does the flow actually look like here?

$\endgroup$

1 Answer 1

1
$\begingroup$

…when I invoke draw API in openGL who does the actual job of drawing/coloring of the actual pixels on the screen?

The GPU does. (At least, if there is one; there are also “software” OpenGL implementations which use the CPU alone.)

But there are intermediate steps between “called an OpenGL function” and “drawing is performed by the GPU”; the GPU does not know what to do with OpenGL functions. (Once upon a time, this might have been less true, but today, GPU architectures are very different from the basic concepts of OpenGL.)

Does openGL has library implementation of draw that sends the instructions on how to draw shapes? or draw API hits the graphics processing unit …

When you load the OpenGL API, you get a set of functions that were provided by the installed OpenGL implementation. Those functions may do whatever they want as long as the end result is drawing stuff according to the OpenGL specification.

In the typical case, those functions are provided along with the GPU driver by your GPU vendor, and those functions, when they execute inside your program, translate the OpenGL instructions into something that better suits the specific GPU model you have, then use system calls to send those translated instructions to the GPU driver (which handles requests from all the separate programs asking to use the GPU).

The GPU driver will then send those translated instructions to the GPU over the system bus, and the GPU executes them, causing shapes to be drawn into GPU framebuffer memory. (That framebuffer will then end up sent to the actual video output, on a separate schedule. And there may be additional steps such as window composition before a single application's content appears on screen.)

But all of the details of how all of this works are not part of the OpenGL API — OpenGL just says “if you call these functions in the right way, there will be a picture”, and leaves it up to the implementation to choose a means.

$\endgroup$
4
  • $\begingroup$ great that helps, can you also suggest a structured learning blog/videos/course for understanding the above and the flow in more detail that also talks about all the things that a GPU does to draw the shape on screen. $\endgroup$ Apr 12 at 15:46
  • $\begingroup$ @Himanshuman No, I don't have any recommendations (I don't tend to learn things myself that way), and that's off-topic here. $\endgroup$
    – Kevin Reid
    Apr 13 at 15:56
  • $\begingroup$ Discussion in the comments regarding learning material for the on question topic is off topic? Okay if you say so! All I wanted to know was how exactly to learn the above things and from where? $\endgroup$ Apr 13 at 16:17
  • $\begingroup$ @Himanshuman Requests for off-site resources are off-topic here and on most Stack Exchange sites. (Answers may contain links to further resources on the topic asked about, but as I said, I don't myself have any to recommend.) $\endgroup$
    – Kevin Reid
    Apr 13 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.