[Solved] SDL_RWread shown OpenGL ES related error wierdly

The error in question is

Failed loading _glFramebufferTextureMultisampleMultiviewOVR: undefined symbol: __glFramebufferTextureMultisampleMultiviewOVR

Such error shown by SDL_GetError() after SDL_RWread() from a .dds file that encapsulates ETC2-RGBA compressed texture inside with mipmaps. But no need to pay attention to such compressed texture format as the code execution doesn’t reach that part to create OpenGL texture just yet. DDS file format is read just fine just that we knew its layout. Yep, again, this error shown after I successfully read DDS header, and about to begin reading image data section. See the code at the bottom.

Thing is a code base on both PC and Android. PC works fine although PC uses different compressed texture format; again compressed format is not problem here (Linux, Ubuntu 18.04 with Mesa driver). But it shown error on Android (Android 6.0 with OpenGL ES 3.1 maximum suport, cross compiled against NDK 19c). Both Android, and PC uses OpenGL ES 3.0 created context and hooked up properly with SDL2 (12373:8feb5da6f2fb release 2.0.9), as well I use GLAD to load OpenGL functions.

I checked glFramebufferTextureMultisampleMultiviewOVR is available in run-time testing on device itself via GL_OVR_multiview_multisampled_render_to_texture.

I’m curious as the error shown about OpenGL related functionality but I’m reading from file, so I’m not sure what did I miss.

The code is pretty much straight forward

  SDL_RWops *file = SDL_RWFromFile(path, "rb");
  if (file == NULL)
    KRR_LOGE("Unable to open file for read %s", path);
    return false;
  <consecutive SDL_RWread calls to progressively read file, 
     section by section of DDS format>
  // -- now we're at image + mipmaps section --
  // define images buffer space
  unsigned char* images_buffer = calloc(1, images_size * sizeof(unsigned char));
  // read all image data into buffer
  f_nobj_read = SDL_RWread(file, images_buffer, images_size, 1);
  if (f_nobj_read != 1)
    KRR_LOGE("Error read images data: %s", SDL_GetError());
    // close file
    file = NULL;
    return false;

Any idea of what happen?

I’m checking about file size whether I’ve read more bytes than the file has or not.

Ok, solved the problem

Turned out not OpenGL problem. I did actually read passed the actual file size.
Before I calculating all images size (included mipmaps) by iterating through all mipmaps level and consult OpenGL ES doc to calculate image size for such certain compressed texture format and use such result value to read from file. Hmm, I guess it should not be that way. So instead, I calculate the less of file size from current file offset (via SDL_RWtell). It works now. Thanks