2

I am doing coding in ubuntu 10.10 with kronos headers but i am stuck because whenever i try to compile the code they there is an error comes :

glmapbuffer undeclared glunmapbuffer undeclared

i have gl2.h and gl2ext.h in my header file .Can anyone tell me

If I am doing like this what else can i do :

    glBindBuffer(GL_ARRAY_BUFFER, uiVBO[surfnum]);
    glBufferData(GL_ARRAY_BUFFER, 9*sizeof(GLfloat)*triNum[surfnum], NULL, GL_STATIC_DRAW);
    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);//clean up behind us
Sudhanshu Gupta
  • 2,255
  • 3
  • 36
  • 74
  • Did you take a look at those two header files? The ones that I can access at Khronos do not contain those two methods. http://www.khronos.org/registry/gles/api/2.0/gl2ext.h http://www.khronos.org/registry/gles/api/2.0/gl2.h – Bob Jul 04 '11 at 09:58
  • @bob yaah i have seen it but i think http://www.khronos.org/registry/gles/api/2.0/gl2ext.h contains glMapBufferOES and glUnmapBufferOES .The one with /* GL_OES_mapbuffer */ , If you mean something else , elaborate me. – Sudhanshu Gupta Jul 05 '11 at 03:21

2 Answers2

3

The suffix …OES indicates that those functions are not part of the core OpenGL-ES specification, but are considered optional functionality, very much like …ARB extensions mentioned in standard OpenGL specifications. Like with standard OpenGL the method to access the extension, if available, depends on the target plattform.

However in your case, since you try to compile it on a standard desktop Linux I suggest the following workaround, if you insist on mapping the buffer.

/* before using glMapBufferOES */
#ifdef SYSTEM_HAS_STD_OPENGL
#define glMapBufferOES glMapBuffer
#define glUnmapBufferOES glUnmapBuffer
#endif

Of course you could just fill a proxy array with the data, supply that to glBufferData and not map at all:

glBindBuffer(GL_ARRAY_BUFFER, uiVBO[surfnum]);
size_t buf_size = 9*sizeof(GLfloat)*triNum[surfnum];
GLfloat * const pData = malloc(buf_size);
for(i=0; i<triNum[surfnum]; ++i) {
    memcpy(pData+i*9,   triArray[surfnum][i].pt1, 3*sizeof(GLfloat));
    memcpy(pData+i*9+3, triArray[surfnum][i].pt2, 3*sizeof(GLfloat));
    memcpy(pData+i*9+6, triArray[surfnum][i].pt3, 3*sizeof(GLfloat));
}
glBufferData(GL_ARRAY_BUFFER, buf_size, pData, GL_STATIC_DRAW);
free(pData);
datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • 1
    Hi datenwolf I have changed the question because of the errors coming so can you please take a look at that. – Sudhanshu Gupta Jul 06 '11 at 03:26
  • 1
    @surbhi: Difficult to tell what exactly the problem is from just that code. The error message you get is, because Mesa tells you, that the EGL context you created, will not be hardware accelerated. To tell, why nothing shows up I need to see: Transformation setup, loaded shaders (OpenGL-ES 2 requires that you load shaders) and the outline of the drawing function. – datenwolf Jul 06 '11 at 06:36
  • okk then I am giving typing here the whole code , please tell me where i am lacking because after this only I can go further and thanks for your replies – Sudhanshu Gupta Jul 06 '11 at 08:23
0

The OpenGL ES 2.0 Specification states that buffer object mapping is "not required". Now, the ES 2.0 spec is the oddest specification I've ever seen, since it lists functionality that is "not required." But at the very least, it means that it doesn't have to be present. According to the extension registry, buffer object mapping is governed by the GL_OES_mapbuffer extension.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • 2
    Functionality being optional is very common in embedded environments. For example a embedded GPU may have the computational capabilities, but the whole system has too few RAM to support a certain capability, so it's disabled. – datenwolf Jul 04 '11 at 12:30
  • @Nicol @datenwolf I am doing some way i have edited the Question what else i do to make it work . Please tell me ,. Thank you for your advices – Sudhanshu Gupta Jul 05 '11 at 03:46