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

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

问题描述

我正在通过使用kronos和pvrsdk在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

我已经对此进行了定义,但仍未定义这些函数.所以你知道它有什么变化,以便可以使用它.

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).

查看哪些库,例如 GLEW (关于memcpy的错误是缺少的#include <string.h>)

(the error about memcpy is a missing #include <string.h>)

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

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