1

I was wondering about OpenGL's main interface. Simply, how does the OpenGL DLL call graphics functions? Is there some secret hidden rendering code in C++? If it can call the GPU from a DLL, it should be possible in any C++ program. If so, could I make some API of my own for my programs? Or what? I'm hoping someone here knows. Can someone shed some light on this subject? Thanks in advance!

  • The whole point of OpenGL is to somehow abstract the hardware-related details.... – Basile Starynkevitch Apr 21 '13 at 07:37
  • It's still in a DLL, that's my question. If it's possible to be packed into a DLL, then it's possible to access from a exe. – user2303375 Apr 21 '13 at 07:41
  • 2
    Several GPU manufacturers (notably Nvidia) don't publish enough detailed specifications about their hardware. The only thing they give you is some OpenGL implementation. – Basile Starynkevitch Apr 21 '13 at 07:43
  • Intel has open-sourced their gfx drivers for Linux, if you are curious to poke around, check https://01.org/linuxgraphics/ also, check out http://www.mesa3d.org/ – Necrolis Apr 21 '13 at 08:10

4 Answers4

2

The OpenGL DLL's communicate with Ring 0 like any other application module does, with calls like DeviceIoControl. The exact details of the data passed to those calls is not publicly documented and that's not likely to change. The GPU manufacturers just aren't willing to part with that information all willy nilly like. While it's possible you could create your own API, the details to talk to the driver are not going to be readily available.

Marcelo Cantos
  • 181,030
  • 38
  • 327
  • 365
Captain Obvlious
  • 19,754
  • 5
  • 44
  • 74
  • 1
    Certainly true for NVIDIA, but anybody with too much time can look at the source of the Intel and AMD/ATI drivers. – Mikhail Apr 21 '13 at 08:37
2

First and foremost: Modern OpenGL is not a library and on Windows the DLL doesn't contain a OpenGL implementation that talks to the hardware. The opengl32.dll merely acts as a placeholder, into which the drivers hook their low level functions (called ICD).

I answered it in detail here: https://stackoverflow.com/a/6401607/524368

Community
  • 1
  • 1
datenwolf
  • 159,371
  • 13
  • 185
  • 298
1

In general sense the answer is "yes", but to make it viable, it must necessary be somewhat "Hardware dependent"

What you call "Graphics functions" (something you suppose OGL is based on) at the very bottom level depends on the way the hardware structures the image frames into itself an communicate with the processor.

There are hardware that are just a plane frame buffer and hardware that are capable to manage themselves the rasterization process of a vectorial scene.

There are operating system API that are plane 2d vector and imaging support (like GDI) or even three-dimensional modeling system (like direc3d).

OGL is just an API: it define a consistent set of function prototypes to accomplish a task (describe a 3D scene). The renderimg process is implemented into DLLS that differ depending on the nature of the system they have to work with.

Some of them just operate on their own buffers that treat as raw data for bitmaps to be Blit-ted on the screen via OS native api (see BitBlit), some other translate the OGL calls into calls to specific op-code to specific io-ports of hardware device.

Due to the popularity of OGL, there are also manufacturers that are standardizing the "language" between the library and the devices. So things are not so "linear" as they can seem...

Emilio Garavaglia
  • 20,229
  • 2
  • 46
  • 63
0

Writing directly to hardware registers is how graphics programming was done before OpenGL and other standardised graphics APIs were introduced.

Generally speaking, it was a nightmare to write for, and almost impossible to debug. Higher level APIs were invented for a reason.

The closest you can get to hardware these days is on the consoles, where you still have much lower level access than on the PC, but even that access is abstracted away more then it was in the past.

If you really want to do it, you can, but you'll basically be writing your own driver if you're not writing your own OS as well, and you wont find much publicly available documentation on modern GPUs.