Debugging the hello-gl2 project with Visual Studio

This quickstart guide shows how to build and debug a simple Android App with a native library.

Before you begin, please install VisualGDB 2.0 or later (ensure that “Android Edition” is checked in the installer). If you are not familiar with VisualGDB, please first go through the Android Quickstart tutorial.

 Warning! The Android Emulator does
not support OpenGL. You will need a real device for this

  1. Start Visual Studio. Select File->New project->VisualGDB->Android Project Wizard.01-newproject
  2. Select the directory for the project, enter a project name (e.g. GL2Wrapper) and press OK.
  3. Select “Clone a sample from NDK”:02-clone
  4. Select the hello-gl2 project from the list:03-gl2
  5. Select a platform for the newly created project (in this example we select Android 2.3.3):04-platform
  6. When done, press the Finish button. A new Visual Studio project will be created. Select Build->Build Solution to build the project:05-project
  7. Plug in your Android Device. Do not use the Android emulator as it does not support OpenGL. Enable USB debugging and install the USB driver if needed. See this guide for more details.
  8. Put a breakpoint on the line containing the glClearColor() call inside the renderFrame() function.
  9. Start debugging by selecting Debug -> Start Debugging with GDB in VIsual Studio.
  10. The app will be automatically deployed and launched and the breakpoint will be hit:07-bkpt
  11. Hover the mouse over the glTriangleVertices definition above renderFrame(). Then click on the “+” symbol. Finally, click on the “0.5” value so that Visual Studio starts editing it.
  12. Replace “0.5” with “1” and press Enter:08-change
  13. Remove the breakpoint and press F5 to continue running the App.
  14. Observe that the triangle shape has changed after we have modified glTriangleVertices:09-triangles
  15. When done, press Shift+F5 to stop the debugging session.