glad

授权协议 View license
开发语言 C/C++
所属分类 程序开发、 图形/图像处理
软件类型 开源软件
地区 不详
投 递 者 越风史
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

glad

GL/GLES/EGL/GLX/WGL Loader-Generator based on the official specs.

Use the webservice to generate the files you need!

#include <glad/glad.h>

int main()
{
    // -- snip --

    GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", NULL, NULL);
    glfwMakeContextCurrent(window);

    if (!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress)) {
        std::cout << "Failed to initialize OpenGL context" << std::endl;
        return -1;
    }

    glViewport(0, 0, WIDTH, HEIGHT);

    // -- snip --

The full code: hellowindow2.cpp.

Glad 2

Glad 2 is becoming mature and is pretty stable now, consider using theglad2 branch or its webservice.

There is no need to switch, if you don't want to. I will support both versions.

Glad2 brings several improvements and new features:

  • Better EGL, GLX, WGL support
  • Vulkan Support
  • Rust Support
  • More Generator Features (e.g. header only)
  • Better XML-Specification parsing
  • Better Web-Generator
  • Better Cmake support
  • Better Examples
  • Better CLI
  • Better Loader
  • Better API

If you're using glad for more than GL, I highly recommend checking out glad2.

Usage

If you don't want to install glad you can use the webservice

Otherwise either install glad via pip:

# Windows
pip install glad

# Linux
pip install --user glad
# Linux global (root)
pip install glad

To install the most recent version from Github:

pip install --upgrade git+https://github.com/dav1dde/glad.git#egg=glad

Or launch glad directly (after cloning the repository):

python -m glad --help

Installing and building glad via vcpkg

You can download and install glad using the vcpkg dependency manager:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
vcpkg install glad

The glad port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.

When integrating glad into your build system the --reproducible option is highly recommended.

Generators

C/C++

struct gladGLversionStruct {
    int major;
    int minor;
};

extern struct gladGLversionStruct GLVersion;

typedef void* (* GLADloadproc)(const char *name);

/*
 * Load OpenGL using the internal loader.
 * Returns the true/1 if loading succeeded.
 *
 */
int gladLoadGL(void);

/*
 * Load OpenGL using an external loader like SDL_GL_GetProcAddress.
 *
 * Substitute GL with the API you generated
 *
 */
int gladLoadGLLoader(GLADloadproc);

/**
 * WGL and GLX have an unload function to free the module handle.
 * Call the unload function after your last GLX or WGL API call.
 */
void gladUnloadGLX(void);
void gladUnloadWGL(void);

glad.h completely replaces any gl.h or gl3.h only include glad.h.

if(!gladLoadGL()) { exit(-1); }
    printf("OpenGL Version %d.%d loaded", GLVersion.major, GLVersion.minor);

    if(GLAD_GL_EXT_framebuffer_multisample) {
        /* GL_EXT_framebuffer_multisample is supported */
    }

    if(GLAD_GL_VERSION_3_0) {
        /* We support at least OpenGL version 3 */
    }

On non-Windows platforms glad requires libdl, make sure to link with it (-ldl).

Note, there are two kinds of extension/version symbols, e.g. GL_VERSION_3_0 andGLAD_VERSION_3_0. Latter is a runtime boolean (represented as integer), whereasthe first (not prefixed with GLAD_) is a compiletime-constant, indicating that thisheader supports this version (the official headers define these symbols as well).The runtime booleans are only valid after a successful call to gladLoadGL or gladLoadGLLoader.

C/C++ Debug

The C-Debug generator extends the API by these two functions:

// this symbol only exists if generated with the c-debug generator
#define GLAD_DEBUG
typedef void (* GLADcallback)(const char *name, void *funcptr, int len_args, ...);

/*
 * Sets a callback which will be called before every function call
 * to a function loaded by glad.
 *
 */
GLAPI void glad_set_pre_callback(GLADcallback cb);

/*
 * Sets a callback which will be called after every function call
 * to a function loaded by glad.
 *
 */
GLAPI void glad_set_post_callback(GLADcallback cb);

To call a function like glGetError in a callback prefix it with glad_, e.g.the default post callback looks like this:

void _post_call_callback_default(const char *name, void *funcptr, int len_args, ...) {
    GLenum error_code;
    error_code = glad_glGetError();

    if (error_code != GL_NO_ERROR) {
        fprintf(stderr, "ERROR %d in %s\n", error_code, name);
    }
}

You can also submit own implementations for every call made by overwritingthe function pointer with the name of the function prefixed by glad_debug_.

E.g. you could disable the callbacks for glClear with glad_debug_glClear = glad_glClear, whereglad_glClear is the function pointer loaded by glad.

The glClear macro is defined as #define glClear glad_debug_glClear,glad_debug_glClear is initialized with a default implementation, which callsthe two callbacks and the real function, in this case glad_glClear.

FAQ

How do I build glad or how do I integrate glad?

Easiest way of using glad is through the webservice.

Alternatively glad integrates with:

Thanks for all the help and support maintaining those!

glad includes windows.h #42

Since 0.1.30: glad does not include windows.h anymore.

Before 0.1.30:Defining APIENTRY before including glad.h solves this problem:

#ifdef _WIN32
    #define APIENTRY __stdcall
#endif

#include <glad/glad.h>

But make sure you have the correct definition of APIENTRY for platforms which define _WIN32 but don't use __stdcall

What's the license of glad generated code?

#101#253

The glad generated code itself is any of Public Domain, WTFPL or CC0,the source files for the generated code are under various licensesfrom Khronos.

Now the Apache License may apply to the generated code (not a lawyer),but see this clarifying comment.

Glad also adds header files form Khronos,these have separated licenses in their header.

Contribute

Contributing is easy! Found a bug? Message me or make a pull request! Added a new generator backend?Make a pull request!

Special thanks for all the people who contributed and are going to contribute!Also to these who helped me solve a problem when I simply could not think of a solution.

  • OpenGL为什么配置GLAD库及GLFW库 关于标题之原因,在这里浅谈下,欢迎补充~ openGL只是一个标准/规范,具体的实现是由驱动开发商针对特定显卡实现的。 GLFW:是一个专门针对OpenGL的C语言库,它提供了一些渲染物体所需的最低限度的接口。它允许用户 创建OpenGL上下文,定义窗口参数以及处理用户输入。利用它可以创建窗口、处理键盘鼠标等事件。 GLAD:由于OpenGL驱动版本众

  • 目标 后知后觉发现windows上可以跑openGL 4.x(也许是我脑子混乱,总感觉windows不支持openGL)。于是重操旧业,配置一下。没想到,这一配就是半个多小时,记录一下踩的雷。 初始环境 VS 2022, 这个无所谓。 cmake 3.22, 这个也无所谓,但是不要太低了,建议在3.20以上。 glfw3.3.6, 官网下载最新的即可,下载下来以后是source code,得稍微编

  • 场景: OpenGL项目工程搭建,配置相关环境 问题描述 编程OpenGL程序时出现的错误: fatal error C1189: #error: OpenGL header already included, remove this include, glad already provides it 原因分析: #include <iostream> #include <GLFW/glfw3.h

  • 前言      GLFW  = GLUT + OpenGL的组合.     GLFW官网:http://www.glfw.org     GLUT (OpenGL Utility Toolkit)是处理OpenGL程式的工具库.     GLFW: GLFW是一个专门针对OpenGL的C语言库,它提供了一些渲染物体所需的最低限度的接口。它允许用户创建OpenGL上下文,定义窗口参数以及处理用户输入

  • 一、下载所需的库 GLAD下载链接:https://glad.dav1d.de/ (glad它是个在线服务,我们需要告诉glad我们选择的OpenGL版本,glad根据选择的版本加载所需的函数。 点击后,选择对应的语言(我是c++),对应的version(3.3以上版本),对应的模式(core) 其他默认,下面记得小框框 勾选generate a loader,然后点击右下角generate,网站

  • 1. 安装vs2022 https://visualstudio.microsoft.com 只需要选择 Desktop development with C++ 组件,其它组件都不用选。C++组件中要手动勾上C++ Clang tools,其它的保持默认状态即可. 2. 打开vs2022, 创建一个新项目idealand,创建同名的solution文件夹, 在solution文件夹中创建libs

 相关资料
  • 我用python和Glade创建了一个unity指示器小程序。下面是点击指示器小程序时出现的截图。您可以看到首选项菜单。单击此首选项菜单时,将打开一个新窗口。 现在的问题是当我点击关闭按钮时,整个应用程序就存在了。 触发首选项窗口的代码如下所示: preference.py具有以下代码:

  • WinRAR 加密和解密程序部分来自 Brian Gladman 的 AES 实现,按照下列条件进行许可: 版权所有 (c) 2002, Dr Brian Gladman < >, Worcester, UK. 保留所有权利。 许可条款 本软件源代码及二进制形式(无论是否改变)允许免费分发和使用,但有以下前提: 此源代码的分发应包含上述版权告示、本条件列表和以下声明; 二进制形式的分发应在文档及其

  • Glade 是 RAD (快速应用开发)工具,用于创建基于 GTK 工具包和 GNOME 桌面。 其界面是类似于 GIMP ,可以进行定制,甚至嵌入到 Anjuta。Glade 包括一些接口模块,如文本框,对话框标签,数字输入,复选框,菜单,使界面的开发更快。界面设计存储为XML 格式,从而使这些设计可以方便地与外部接口结合。安装 Glade 也很简单。例如,在 Fedora 中,您可以敲入命令

  • Glade To Code 是根据 Glade 文件生成指定语言的 GTK 代码的工具 使用说明 python3 glade-to-code.py -l [语言类型] -i [输入 Glade 文件路径] -o [输出源代码文件路径] 提示 如果 Glade 文件中 GTK 组件的 ID 为空, 则不会生成对应的代码。 参数说明 -l, --lang= 语言类型,可选项:

相关阅读

相关文章

相关问答

相关文档