androidvisual-studiovisual-c++opengl-es-3.0

How to include OpenGLES 3 in Visual Studio (Android)


I'm trying to use Visual Studio to make an Android app with C++ / OpenGLES. I started with the template project "OpenGLES Application (Android, iOS)" but this uses OpenGLES 1, and it seems in order to use VAOs I need to upgrade this to OpenGLES 3 (or 2 with extensions?). But I keep getting the compile error undefined reference to 'glGenVertexArrays'.

By default, the template project includes GLES/gl.h. I've tried replacing this with GLES3/gl3.h, which makes Visual Studio recognize glGenVertexArrays (I can go to the definition, etc), but when I build the project I still get the undefined reference error.

I've also tried putting the path to gl3.h in the project settings under "C/C++ Additional Include Directories," but this doesn't seem to have an effect.

Is the problem with the includes or the project settings or something else entirely?

Note: I'm using Visual Studio 2019


Solution

  • I added GLESv3 as a Library Dependency (under project Properties > Linker > Input) instead of GLESv1_CM, and that fixed the error!