OpenGL-ES 2.0 中未声明的 glMapBuffer [英] glMapBuffer undeclared in OpenGL-ES 2.0

查看:64
本文介绍了OpenGL-ES 2.0 中未声明的 glMapBuffer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过使用 kronos 和 pvrsdk .Now 代码在 ununtu 10.10 中做 Opengl-es 2.0

I am doing Opengl-es 2.0 in ununtu 10.10 through the use of kronos and pvrsdk .Now code

#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>

==========|||||||||||||||||||||||||||||||||===================

==========|||||||||||||||||||||||||||||||||||===================

GLfloat *pData = glMapBufferOES (GL_ARRAY_BUFFER, GL_WRITE_ONLY_OES);
            for(i=0; i<triNum[surfnum]; ++i,pData+=9)
            {
                 memcpy(pData, triArray[surfnum][i].pt1, 3*sizeof(GLfloat));
                 memcpy(pData+3, triArray[surfnum][i].pt2, 3*sizeof(GLfloat));
                 memcpy(pData+6, triArray[surfnum][i].pt3, 3*sizeof(GLfloat));
            }
            glUnmapBufferOES (GL_ARRAY_BUFFER);

错误:

src/Hello.cpp: In function 'int main(int, char**)':
src/Hello.cpp:279: error: 'glMapBufferOES' was not declared in this scope
src/Hello.cpp:282: error: 'memcpy' was not declared in this scope
src/Hello.cpp:286: error: 'glUnmapBufferOES' was not declared in this scope

我知道这些在 gl2ext.h 我也包含了这个文件,但它仍然给出错误,我缺少一些东西请告诉我.你可以向我询问任何其他问题或信息.

I know that these are in gl2ext.h I have included this file also but still its giving error there is something i am missing please tell me.You can ask me for any other question or information.

在我的 glext.h 中:

In my glext.h :

/* GL_OES_mapbuffer */
#ifndef GL_OES_mapbuffer
#define GL_OES_mapbuffer 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access);
GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target);
GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, void** params);
#endif
typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access);
typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target);
typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname,     void** params);
#endif

我已经定义了这个,但它仍然将这些功能作为 undeclared .所以你知道它有什么变化以便可以使用吗?

i have this defined already still its giving these functions as undeclared . so do you know anychange in it so that it cam be used.

推荐答案

与普通"OpenGL 一样,您必须定义函数指针并显式加载超出基本框架"的功能.

As with "normal" OpenGL, you have to define function pointers and explicitly load functionality that goes beyond "bare bones".

如果你看标题,你会看到 #ifdef GL_GLEXT_PROTOTYPES 块,这会导致函数原型没有被生成(事实上,我不确定为什么生成原型的选项根本存在,它们对任何人都没有真正的用处).
之后,您会看到 PFNGLMAPBUFFEROESPROC 的 typedef.这就是你需要的.

If you look at the header, you'll see the #ifdef GL_GLEXT_PROTOTYPES block, which causes the function prototype not being generated (in fact, I'm not sure why the option to generate prototypes exists at all, they are not really useful to anyone).
Following that, you see the typedef of PFNGLMAPBUFFEROESPROC. That's what you need.

您必须声明一个全局函数指针,例如 extern PFNGLMAPBUFFEROESPROC glMapBufferOES; 并在启动时对其进行初始化(在检查扩展是否存在之后).

You'll have to declare a global function pointer such as extern PFNGLMAPBUFFEROESPROC glMapBufferOES; and initialize it at startup (after checking presence of the extension).

看看有哪些库,例如 GLEWGlee 做.

Look at what libraries such as GLEW or Glee do.

(关于memcpy的错误是缺少#include <string.h>)

这篇关于OpenGL-ES 2.0 中未声明的 glMapBuffer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆