glMapBuffer undeclared in OpenGL-ES 2.0

女生的网名这么多〃 提交于 2019-12-01 06:46:21

问题


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

Error :

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

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.

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.


回答1:


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

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.

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

Look at what libraries such as GLEW or Glee do.

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




回答2:


putting #include <OpenGLES/ES2/glext.h> fixed my problem



来源:https://stackoverflow.com/questions/6567042/glmapbuffer-undeclared-in-opengl-es-2-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!