zoukankan      html  css  js  c++  java
  • glext; glew, glee这些library的原理(转)

    下面就是glext为我们做的事:

    (1), 根据显卡厂商对某个extension的具体说明来定义一些宏.

    #define GL_ARRAY_BUFFER_ARB 0x8892 //具体的地址是在各个specification中定义的.

    #define GL_STATIC_DRAW_ARB 0x88E4

    (2), 声明一些函数指针的类型.

    typedef void (APIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer);

    typedef void (APIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers);

    typedef void (APIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers);

    typedef void (APIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, int size, const GLvoid *data, GLenum usage);

    然后在我自己的实现中就需要做以下的事:

    (3). 声明定义一些函数指针:

    PFNGLGENBUFFERSARBPROC glGenBuffersARB = NULL;

    PFNGLBINDBUFFERARBPROC glBindBufferARB = NULL;

    PFNGLBUFFERDATAARBPROC glBufferDataARB = NULL;

    PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB = NULL;

    (4). 利用wglGetProcAddress函数取得各个函数的地址指针.

    glBindBufferARB = (PFNGLBINDBUFFERARBPROC)wglGetProcAddress("glBindBufferARB");

    glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB");

    glBufferDataARB = (PFNGLBUFFERDATAARBPROC)wglGetProcAddress("glBufferDataARB");

    而其实在glATI.h, wglATI.h, ATIExtensions.h, and ATIExtensions.c中也是这么做的.

    那些glew, glee就将上面4步都给我们做了.

    所以当使用extensions时候,

    要么是下载glext回来,自己提供源代码实现(3, 4)两步.

    要么是直接用glew or glee.

  • 相关阅读:
    053389
    053388
    053387
    053386
    053385
    Docker简单部署Ceph测试集群
    docker部署Ceph分布式存储集群
    PIC单片机开发环境MPLAB X IDE
    MPLAB X安装,PIC单片机开发环境的搭建记录。
    MPLAB X IDE开发环境
  • 原文地址:https://www.cnblogs.com/madfrog/p/1765243.html
Copyright © 2011-2022 走看看