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.

转载于:https://www.cnblogs.com/madfrog/archive/2010/06/25/1765243.html

本文链接:https://my.lmcjl.com/post/16487.html

展开阅读全文

4 评论

留下您的评论.