开发者

glMapBuffer undeclared in 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);

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_PROT开发者_运维问答OTYPES
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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜