Why use 'glad' library for opengl initialization?

Ivan P.

I am learning now OpenGL and writing some geometrical abstractions over it for personal usage. I want my code to be maximally portable and I want to have GL context initialized in caller code (by means of FLTK, wxWidgets, WinAPI or any else supported platform).

I am reading now this popular article: https://learnopengl.com/Getting-started/Creating-a-window

Authors suggest there to use GLAD library, because this library provides creation of GL context (which does not fit me) and also it is used for 'retrieving addresses of functions' (quote: "Since there are many different versions of OpenGL drivers, the location of most of its functions is not known at compile-time and needs to be queried at run-time.").

My question is the following:

Does compiler really cannot get addresses of Opengl functions from GL-related .obj files which I specify in Linker Settings of Visual Studio? Do I really need to use wglGetProcAddress routine to refer to OpenGL functions? Is it possible to use OpenGL functions like any other functions from linked headers and .obj files?

derhass

Authors suggest there to use GLAD library, because this library provides creation of GL context (which does not fit me)

No, GLAD does not create or manage GL contexts in any way, and the website https://learnopengl.com/Getting-started/Creating-a-window never claims otherwise. They use GLFW for context and window management.

Does compiler really cannot get addresses of Opengl functions from GL-related .obj files which I specify in Linker Settings of Visual Studio?

No.

First of all, you do not specify OpenGL-related .obj files for the linker, but on Windows, you might use opengl32.lib, which is the import library file for opengl32.dll which comes with every windows version since Windows 95.

However, this DLL does not contain the OpenGL implementation you are typically using, but it contains Microsoft's OpenGL 1.1 GDI software rasterizer. The actual OpenGL implementation on windows is provided by an Installable Client Driver (ICD) which comes with your graphics driver. For OpenGL 1.0 and 1.1 functions, opengl32.dll will act as a trampoline and will forward the calls to the actual ICD DLL.

If you want to call any OpenGL function beyond OpenGL 1.1 (and that one is from 1997), you have to use the OpenGL extension mechanism in every case, as opengl32.dll does not provide these entry points at all, and the compiler/linker will of course not find them.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to use Glad in DLL and exe

分類Dev

Why does initialization of local static objects use hidden guard flags?

分類Dev

Why static final variable use static method initialization need synchronized?

分類Dev

OpenGL library not linking

分類Dev

Why does Go compiler not find a library I use?

分類Dev

Why Android Studio is forcing to use Androidx from Android support library?

分類Dev

why view pager class is not in android.app package , I don't want to use support library

分類Dev

Why is array initialization with brackets () marked as error by compilers?

分類Dev

How to use Library as a variable

分類Dev

Use external library in my Arduino library

分類Dev

GLADの組み込みローダーの代わりに外部OpenGLローダー関数を使用する必要があるのはなぜですか?

分類Dev

Why do OpenGL methods not return anything?

分類Dev

Lazy Initialization sounds and works great. Why not always default to using lazy initialization?

分類Dev

How to use this library called bezierjs?

分類Dev

How to use Library in IntelliJ IDEA

分類Dev

Use library in windows form application

分類Dev

How to use ImageLoader of Volley Library?

分類Dev

Import use of header only library

分類Dev

Is SDL Renderer useless if I use opengl for drawing?

分類Dev

Which type of float to use in swift OpenGL?

分類Dev

Does XNA/OpenGL use left handed matrices?

分類Dev

Why instance initialization block is not throwing compile time error for duplicate entry?

分類Dev

Why class data members can't be initialized by direct initialization syntax?

分類Dev

Initialization of an array of structure initializes all member of a single element, why?

分類Dev

Why does struct attribute declaration and initialization order behaves like this?

分類Dev

Why the standard preferred round brackets initialization for `make_<something>`?

分類Dev

Why are my environment variables not being loaded properly before initialization code?

分類Dev

How can I use the for loop's initialization variable as a placeholder in C?

分類Dev

use of @Value Spring annotation during Controller initialization issue

Related 関連記事

  1. 1

    How to use Glad in DLL and exe

  2. 2

    Why does initialization of local static objects use hidden guard flags?

  3. 3

    Why static final variable use static method initialization need synchronized?

  4. 4

    OpenGL library not linking

  5. 5

    Why does Go compiler not find a library I use?

  6. 6

    Why Android Studio is forcing to use Androidx from Android support library?

  7. 7

    why view pager class is not in android.app package , I don't want to use support library

  8. 8

    Why is array initialization with brackets () marked as error by compilers?

  9. 9

    How to use Library as a variable

  10. 10

    Use external library in my Arduino library

  11. 11

    GLADの組み込みローダーの代わりに外部OpenGLローダー関数を使用する必要があるのはなぜですか?

  12. 12

    Why do OpenGL methods not return anything?

  13. 13

    Lazy Initialization sounds and works great. Why not always default to using lazy initialization?

  14. 14

    How to use this library called bezierjs?

  15. 15

    How to use Library in IntelliJ IDEA

  16. 16

    Use library in windows form application

  17. 17

    How to use ImageLoader of Volley Library?

  18. 18

    Import use of header only library

  19. 19

    Is SDL Renderer useless if I use opengl for drawing?

  20. 20

    Which type of float to use in swift OpenGL?

  21. 21

    Does XNA/OpenGL use left handed matrices?

  22. 22

    Why instance initialization block is not throwing compile time error for duplicate entry?

  23. 23

    Why class data members can't be initialized by direct initialization syntax?

  24. 24

    Initialization of an array of structure initializes all member of a single element, why?

  25. 25

    Why does struct attribute declaration and initialization order behaves like this?

  26. 26

    Why the standard preferred round brackets initialization for `make_<something>`?

  27. 27

    Why are my environment variables not being loaded properly before initialization code?

  28. 28

    How can I use the for loop's initialization variable as a placeholder in C?

  29. 29

    use of @Value Spring annotation during Controller initialization issue

ホットタグ

アーカイブ